All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Yair Podemsky <ypodemsk@redhat.com>
Cc: will@kernel.org, aneesh.kumar@linux.ibm.com, npiggin@gmail.com,
	peterz@infradead.org, arnd@arndb.de, linux-arch@vger.kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	mtosatti@redhat.com, ppandit@redhat.com, alougovs@redhat.com,
	David Hildenbrand <david@redhat.com>
Subject: Re: [PATCH] mm/mmu_gather: send tlb_remove_table_smp_sync IPI only to MM CPUs
Date: Sun, 12 Mar 2023 13:25:24 -0700	[thread overview]
Message-ID: <20230312132524.c37abfffe2c70eeda20f3217@linux-foundation.org> (raw)
In-Reply-To: <20230312080945.14171-1-ypodemsk@redhat.com>

On Sun, 12 Mar 2023 10:09:45 +0200 Yair Podemsky <ypodemsk@redhat.com> wrote:

> Currently the tlb_remove_table_smp_sync IPI is sent to all CPUs
> indiscriminately, this causes unnecessary work and delays notable in
> real-time use-cases and isolated cpus, this patch will limit this IPI to
> only be sent to cpus referencing the effected mm and are currently in
> kernel space.
> 
> ...
>
> --- a/mm/mmu_gather.c
> +++ b/mm/mmu_gather.c
> @@ -191,7 +192,15 @@ static void tlb_remove_table_smp_sync(void *arg)
>  	/* Simply deliver the interrupt */
>  }
>  
> -void tlb_remove_table_sync_one(void)
> +static bool cpu_in_kernel(int cpu, void *info)
> +{
> +	struct context_tracking *ct = per_cpu_ptr(&context_tracking, cpu);
> +	int statue = atomic_read(&ct->state);

Strange identifier.  Should be "state"?

> +	//will return true only for cpu's in kernel space

Please use /* */ style comments

And use "cpus" rather than "cpu's" - plural, not possessive.

> +	return !(statue & CT_STATE_MASK);

Using

	return state & CT_STATE_MASK == CONTEXT_KERNEL;

would more clearly express the intent.

> +}

And...  surely this function is racy.  ct->state can change value one
nanosecond after cpu_in_kernel() reads it, so cpu_in_kernel()'s return
value is now wrong?

  reply	other threads:[~2023-03-12 20:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-12  8:09 [PATCH] mm/mmu_gather: send tlb_remove_table_smp_sync IPI only to MM CPUs Yair Podemsky
2023-03-12 20:25 ` Andrew Morton [this message]
2023-03-20  8:49 ` Peter Zijlstra
2023-03-22 14:11   ` ypodemsk
2023-03-24 15:13     ` Will Deacon
2023-03-26  7:40       ` ypodemsk

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=20230312132524.c37abfffe2c70eeda20f3217@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=alougovs@redhat.com \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=arnd@arndb.de \
    --cc=david@redhat.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mtosatti@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=peterz@infradead.org \
    --cc=ppandit@redhat.com \
    --cc=will@kernel.org \
    --cc=ypodemsk@redhat.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 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.