public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Bin Yang <bin.yang@intel.com>,
	tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
	x86@kernel.org, linux-kernel@vger.kernel.org, "Gross,
	Mark" <mark.gross@intel.com>
Subject: Re: [PATCH v2] x86/mm: fix cpu stuck issue in __change_page_attr_set_clr
Date: Thu, 5 Jul 2018 15:20:54 -0700	[thread overview]
Message-ID: <451f54b6-e5f5-cf30-f73f-c155c293cbe7@intel.com> (raw)
In-Reply-To: <1530769636-26603-1-git-send-email-bin.yang@intel.com>

On 07/04/2018 10:47 PM, Bin Yang wrote:
> When changing a 4K page attr inside 1G/2M large page range,
> __change_page_attr() will call try_preserve_large_page() to decide
> to split the big page or not. And try_preserve_large_page() will
> call static_protections() to check all 4K pages inside the large page
> range one by one. The check loop is very inefficient. In worst case,
> static_protections() will be called for 1G/4K (262144) times.

I wrote this before I read the entire thread and Thomas's analysis, but
I think we came to the same conclusion.  Here goes anyway:

Let me make sure I got this right.

1. free_init_pages() frees a single 4k page
2. set_memory_rw() tries to set that 4k range read-write
3. try_preserve_large_page()->_lookup_address_cpa() finds a 1GB
   page covering that 4k range.
4. We now go over the 1GB range (outside the 4k one we may or may not be
   changing) to see if it needs to be converted because of
   static_protections()

Correct?

#4 seems insane.  Why is it the new call's job to fix up protections
outside the 4k area which it was called to change?

There's an argument to be made that we need the static_protections()
loop for the area that try_to_preserve_large_page() is being called
over, but by no means do we need that for anything larger.

So, for this patch's purposes, if we do a change_page_attr(), walk down
to the PTE/PMD/PUD/... mapping that virtual address, and find that that
pte fulfills the 'prot' we are going for (adjusted for
static_protections() and for large page prot bits), we are done.
Totally done.  Done-aroo.

      parent reply	other threads:[~2018-07-05 22:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-05  5:47 [PATCH v2] x86/mm: fix cpu stuck issue in __change_page_attr_set_clr Bin Yang
2018-07-05  6:28 ` Thomas Gleixner
2018-07-05 22:20 ` Dave Hansen [this message]

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=451f54b6-e5f5-cf30-f73f-c155c293cbe7@intel.com \
    --to=dave.hansen@intel.com \
    --cc=bin.yang@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.gross@intel.com \
    --cc=mingo@redhat.com \
    --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