From: Steven Rostedt <rostedt@goodmis.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [GIT PULL] ftrace: Check if pages were allocated before calling free_pages()
Date: Wed, 31 Mar 2021 15:03:15 -0400 [thread overview]
Message-ID: <20210331150315.6c38f333@gandalf.local.home> (raw)
In-Reply-To: <CAHk-=whyMxheOqXAORt9a7JK9gc9eHTgCJ55Pgs4p=X3RrQubQ@mail.gmail.com>
On Wed, 31 Mar 2021 11:03:21 -0700
Linus Torvalds <torvalds@linux-foundation.org> wrote:
> I found another bug in there, for example:
>
> ftrace_number_of_pages -= 1 << order;
>
> is also wrong if order is negative.
True, but ftrace_number_of_pages is only used for accounting (used to
display the number of pages at boot up and the number in
/sys/kernel/tracing/dyn_ftrace_total_info). If order is negative, this
value could be used to debug what went wrong ;-)
> Doesn't this make the code now make SENSE? Instead of that
> incomprehensible mess it was before?
I'll look into it. This code has been there since pretty much the beginning
and slowly "grew". It suffered the thousand cuts, instead of going in and
doing surgery on making it clean. It hasn't changed in a long time, so it's
due for a clean up as I believe it's in a stable state now.
>
> I dunno. Maybe it's just my "pee in the snow" thing, but honestly, the
> fact that I seem to have found another bug wrt the whole
> 'ftrace_number_of_pages' handling really says that the code was
> garbage.
Again, that variable was just used to see what the page count was. It was
never used for any logic.
>
> And maybe it's just me who doesn't understand the subtle perfection of
> the old code, and I'm being stupid. Feel free to educate me about it.
>
> Final note: note the "TOTALLY UNTESTED" part of the patch. The patch
> CompilesForMe(tm), but please consider it a "how about something like
> this" rather than anything finished.
>
> Also note that I did *not* change the initial "order" calculation
> itself in ftrace_allocate_records() in this patch. I left that
> particular oddity alone. Again, I *think* the math just ends up being
>
> pages = DIV_ROUND_UP(count, ENTRIES_PER_PAGE);
> order = fls(pages)-1;
>
> but the attached patch is not about that, it's about the crazy "pg->size" games.
>
> Linus
>
> PS. TOTALLY UNTESTED!!
Thanks, I'll look at it and see if it doesn't break anything, or if it can
be easily modified to not break anything.
-- Steve
next prev parent reply other threads:[~2021-03-31 19:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-31 13:27 Steven Rostedt
2021-03-31 17:45 ` Linus Torvalds
2021-03-31 18:03 ` Linus Torvalds
2021-03-31 19:03 ` Steven Rostedt [this message]
2021-04-01 20:07 ` Steven Rostedt
2021-04-01 20:18 ` Linus Torvalds
2021-04-01 20:53 ` Steven Rostedt
2021-04-01 20:25 ` Steven Rostedt
2021-03-31 18:51 ` Steven Rostedt
2021-03-31 19:01 ` Linus Torvalds
2021-03-31 18:05 ` pr-tracker-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210331150315.6c38f333@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®