linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Xu, Yanfei" <yanfei.xu@windriver.com>
To: Waiman Long <longman@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Michel Lespinasse <walken@google.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] sched, mm: Optimize current_gfp_context()
Date: Sat, 19 Sep 2020 22:55:28 +0800	[thread overview]
Message-ID: <a6b1ea3c-a186-c807-a0af-19c0149f1402@windriver.com> (raw)
In-Reply-To: <c8f3c589-c4c4-f132-8759-24a44cfa73f4@redhat.com>



On 9/18/20 11:18 PM, Waiman Long wrote:
> On 9/18/20 2:44 AM, Xu, Yanfei wrote:
>> Hi Waiman,
>>
>> On 8/12/20 6:29 AM, Andrew Morton wrote:
>>> On Thu, 18 Jun 2020 17:29:36 -0400 Waiman Long <longman@redhat.com> 
>>> wrote:
>>>
>>>> The current_gfp_context() converts a number of PF_MEMALLOC_* 
>>>> per-process
>>>> flags into the corresponding GFP_* flags for memory allocation. In
>>>> that function, current->flags is accessed 3 times. That may lead to
>>>> duplicated access of the same memory location.
>>>>
>> I have a puzzle about this comment, what's the meaning about "That may
>> lead to duplicated access of the same memory location". After using
>> variable 'pflags', will it not duplicated access the same memory
>> location?
>> Looking forward to your reply :)
> 
> That condition usually won't happen on a non-debug kernel. However, if 
> certain debugging capability is turned on, access to current will be 
> compiled into a bunch of checks and memory accesses. So if current is 
> used multiple times, the same set of codes will be duplicated the same 
> number of times slowing down the operation and increasing code size. By 
> accessing current once, we avoid this overhead in a debug kernel.
> 
> Cheers,
> Longman
> 
Hah, got it.
Thanks for your detailed explain!

cheers,
Yanfei

      reply	other threads:[~2020-09-19 14:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-18 21:29 [PATCH v2] sched, mm: Optimize current_gfp_context() Waiman Long
2020-08-11 22:29 ` Andrew Morton
2020-08-11 23:32   ` Waiman Long
2020-09-18  6:44   ` Xu, Yanfei
2020-09-18 15:18     ` Waiman Long
2020-09-19 14:55       ` Xu, Yanfei [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=a6b1ea3c-a186-c807-a0af-19c0149f1402@windriver.com \
    --to=yanfei.xu@windriver.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=walken@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).