From: Nadav Amit <namit@vmware.com>
To: Dave Hansen <dave.hansen@intel.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Hugh Dickins <hughd@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"x86@kernel.org" <x86@kernel.org>, Linux MM <linux-mm@kvack.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Andy Lutomirski <luto@kernel.org>
Subject: Re: [PATCH] x86/mm/tlb: ignore f->new_tlb_gen when zero
Date: Fri, 8 Jul 2022 17:04:12 +0000 [thread overview]
Message-ID: <4F7D1BBF-9695-4DE2-A40E-2D2546B2BAAE@vmware.com> (raw)
In-Reply-To: <c5edb95c-3ca3-9339-47d6-6304f9bfd708@intel.com>
On Jul 8, 2022, at 7:49 AM, Dave Hansen <dave.hansen@intel.com> wrote:
> ⚠ External Email
>
> On 7/7/22 17:30, Nadav Amit wrote:
>
> You might want to fix the clock on the system from which you sent this.
> I was really scratching my head trying to figure out how you got this
> patch out before Hugh's bug report.
>
>> From: Nadav Amit <namit@vmware.com>
>>
>> Commit aa44284960d5 ("x86/mm/tlb: Avoid reading mm_tlb_gen when
>> possible") introduced an optimization of skipping the flush if the TLB
>> generation that is flushed (as provided in flush_tlb_info) was already
>> flushed.
>>
>> However, arch_tlbbatch_flush() does not provide any generation in
>> flush_tlb_info. As a result, try_to_unmap_one() would not perform any
>> TLB flushes.
>>
>> Fix it by checking whether f->new_tlb_gen is nonzero. Zero value is
>> anyhow is an invalid generation value.
>
> It is, but the check below uses 'f->end == TLB_FLUSH_ALL' as the marker
> for f->new_tlb_gen being invalid. Being consistent seems like a good
> idea on this stuff.
If we get a request to do a flush, regardless whether full or partial,
that logically we have already done, there is not reason to do it.
I therefore do not see a reason to look on f->end. I think that looking
at the generation is very intuitive. If you want, I can add a constant
such as TLB_GENERATION_INVALID.
>
>> In addition, add the missing unlikely() and jump to get tracing right.
>
> There are currently five routes out of flush_tlb_func():
> * Three early returns
> * One 'goto done'
> * One implicit return
>
> The tracing code doesn't get run for any of the early returns, but
> that's intentional because they don't *actually* flush the TLB. We
> don't want to record that flush_tlb_func() flushed the TLB when it
> didn't. There's another tracepoint on the TLB_REMOTE_SEND_IPI side to
> tell where the flushes were requested.
>
> That said, I think the
>
> if (unlikely(local_tlb_gen == mm_tlb_gen))
> goto done;
>
> is arguably buggy, as is the 'goto done' in this hunk:
I was just trying to follow it for consistency. Will remove.
>
> We might want to (eventually) think about doing something like the
> attached patch to make the skipped flushes explicit in the tracing and
> make the return paths out of this function more consistent.
That’s fine with me. I just recommend that you have a single tracing call in
the function, since having too many ruins the generated code.
next prev parent reply other threads:[~2022-07-08 17:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-08 0:30 Nadav Amit
2022-07-08 11:40 ` David Hildenbrand
2022-07-08 15:13 ` Dave Hansen
2022-07-08 16:54 ` Nadav Amit
2022-07-08 17:01 ` Dave Hansen
2022-07-08 17:09 ` Nadav Amit
2022-07-08 18:03 ` Nadav Amit
2022-07-08 14:49 ` Dave Hansen
2022-07-08 17:04 ` Nadav Amit [this message]
2022-07-08 18:54 ` Dave Hansen
2022-07-11 5:19 ` Nadav Amit
2022-07-08 19:21 ` Hugh Dickins
2022-07-08 20:02 ` Nadav Amit
2022-07-08 20:48 ` Hugh Dickins
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=4F7D1BBF-9695-4DE2-A40E-2D2546B2BAAE@vmware.com \
--to=namit@vmware.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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