All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>,
	Linux List Kernel Mailing <linux-kernel@vger.kernel.org>,
	Andy Lutomirski <luto@kernel.org>, Nadav Amit <namit@vmware.com>,
	Dave Hansen <dave.hansen@intel.com>
Subject: Re: [PATCH] x86/tlb: Revert: Align TLB invalidation info
Date: Tue, 16 Apr 2019 10:45:05 -0700	[thread overview]
Message-ID: <CAHk-=whgXyXCy9vHY2hKJ9Pa8PnwdwKo9eOQ3jDbCs_FkdDvkQ@mail.gmail.com> (raw)
In-Reply-To: <20190416080335.GM7905@worktop.programming.kicks-ass.net>

On Tue, Apr 16, 2019 at 1:03 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> Using 320 bytes of stack space for a 40 byte structure is ludicrous and
> clearly not right.

Ack.

That said, I wish we didn't have these stack structures at all. Or at
least were more careful about them. For example, another case of this
struct on the stack looks really iffy too:

                struct flush_tlb_info info;
                info.start = start;
                info.end = end;
                on_each_cpu(do_kernel_range_flush, &info, 1);

note how it only initializes two of the fields, and leaves the others
entirely randomly initialized with garbage?

Yeah, yeah, "do_kernel_range_flush()" only uses those two fields, but
it still makes my skin crawl how we basically pass a largely
uninitialized structure and have other CPU's look at it.

And in another case we do have a nicely initialized structure

    void arch_tlbbatch_flush(struct arch_tlbflush_unmap_batch *batch)
    {
        struct flush_tlb_info info = {
                .mm = NULL,
                .start = 0UL,
                .end = TLB_FLUSH_ALL,
        };

but it looks like it shouldn't have been on the stack in the first
place, because as far as I can tell it's entirely constant, and it
should just be a "static const" structure initialized at compile time.

So as far as I can tell, we could do something like

-static void flush_tlb_func_local(void *info, enum tlb_flush_reason reason)
+static void flush_tlb_func_local(const void *info, enum
tlb_flush_reason reason)
-       struct flush_tlb_info info = {
+       static const struct flush_tlb_info info = {

for that case.

End result: it looks like we have three of these stack things, and all
three had something odd in them.

So very much Ack on that patch, but maybe we could do a bit more cleanup here?

                   Linus

  parent reply	other threads:[~2019-04-16 17:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-16  8:03 [PATCH] x86/tlb: Revert: Align TLB invalidation info Peter Zijlstra
2019-04-16  8:13 ` [tip:x86/urgent] x86/mm/tlb: Revert "x86/mm: Align TLB invalidation info" tip-bot for Peter Zijlstra
2019-04-16 17:45 ` Linus Torvalds [this message]
2019-04-16 18:28   ` [PATCH] x86/tlb: Revert: Align TLB invalidation info Peter Zijlstra
2019-04-17  4:52     ` Nadav Amit

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='CAHk-=whgXyXCy9vHY2hKJ9Pa8PnwdwKo9eOQ3jDbCs_FkdDvkQ@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=namit@vmware.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.