The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Dave Hansen <dave.hansen@intel.com>
Cc: "Jürgen Groß" <jgross@suse.com>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	"Andy Lutomirski" <luto@kernel.org>,
	"Borislav Petkov" <bp@alien8.de>,
	"Ingo Molnar" <mingo@kernel.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Thomas Gleixner" <tglx@kernel.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/mm/pat: fix effective RW computation in lookup_address_in_pgd_attr()
Date: Thu, 16 Jul 2026 16:44:26 +0300	[thread overview]
Message-ID: <aljgOjRTV9xxRubI@kernel.org> (raw)
In-Reply-To: <e3e14e3c-1b09-4f20-8087-0c2764d2eb92@intel.com>

On Thu, Jul 16, 2026 at 06:27:34AM -0700, Dave Hansen wrote:
> On 7/16/26 02:18, Mike Rapoport wrote:
> >> I don't really care how the issue is fixed, but this would result in less
> >> code.
> > But it will be slower 🙂 
> 
> What does "slower" mean here?
 
I've seen ~2% difference per set_memory call in instrumented cpa-test.

> Does it matter in _practice_? Does it measurably slow down something an
> end user might see?

Yes, if a user is loading/unloading a BPF program in a tight loop :)

We can also accumulate flags and push the masking to the final assignment
like Jürgen suggested earlier in this thread:

https://lore.kernel.org/all/f0d7dbe5-5472-409c-9f61-eeefe7d08591@suse.com/
 
I'd prefer to keep the current structure though as I'm planning to pull
lookup_address_in_pgd_attr() to generic code and replace bit checks with
pXd_write()/pXd_exec() helpers.

> Also, I thought we had tests for this gunk. But maybe we're only testing
> the leaf entry permissions or something and not the upper-level
> permissions. I guess we don't often muck with those so this is
> relatively unlikely to have hidden real bugs.
> 
> BTW, my pre-coffee brain struggled with the changelog here:
> 
> 	but _PAGE_RW is bit 1 while *rw only ever holds 0 or 1, so the
> 
> Maybe it was a 0 vs. 1 bit thing, but it still took me way too long.
> Could we do something like:
> 
> _PAGE_RW is 0x2. So consider the accumulation line:
> 
> 	rw &= pXd_flags(*pXd) & _PAGE_RW;
> 
> where rw=0x1 and the right side evaluates down to 0x2. It'll end up doing:
> 
> 	rw = 0x1 & 0x2
> 
> and rw always ends up 0.

Works for me.

-- 
Sincerely yours,
Mike.

  reply	other threads:[~2026-07-16 13:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16  8:10 [PATCH] x86/mm/pat: fix effective RW computation in lookup_address_in_pgd_attr() Mike Rapoport (Microsoft)
2026-07-16  8:37 ` Jürgen Groß
2026-07-16  8:46   ` Juergen Gross
2026-07-16  9:18   ` Mike Rapoport
2026-07-16 12:35     ` David Laight
2026-07-16 12:46       ` Juergen Gross
2026-07-16 12:49         ` David Laight
2026-07-16 12:55           ` Jürgen Groß
2026-07-16 13:27     ` Dave Hansen
2026-07-16 13:44       ` Mike Rapoport [this message]
2026-07-16 13:50         ` Dave Hansen

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=aljgOjRTV9xxRubI@kernel.org \
    --to=rppt@kernel.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@kernel.org \
    --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