mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Yeo Reum Yun <YeoReum.Yun@arm.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>,
	Catalin Marinas <Catalin.Marinas@arm.com>,
	Mark Rutland <Mark.Rutland@arm.com>,
	Will Deacon <will@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Aaron Lu <aaron.lu@intel.com>
Subject: Re: [RFC PATCH] sched: Add missing memory barrier in switch_mm_cid
Date: Tue, 12 Mar 2024 14:07:18 -0400	[thread overview]
Message-ID: <b7660de7-03ad-4d6c-b135-998d2cc0c80e@efficios.com> (raw)
In-Reply-To: <AM0PR08MB428936EACB47856176BFDD8CFB242@AM0PR08MB4289.eurprd08.prod.outlook.com>

On 2024-03-11 04:45, Yeo Reum Yun wrote:
> Hi. Mathieu. Sorry to late answer.
> 
>> diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
>> index 35389b2af88e..0d5e54201eb2 100644
>> --- a/arch/x86/include/asm/barrier.h
>> +++ b/arch/x86/include/asm/barrier.h
>> @@ -79,6 +79,9 @@ do {                                                                  \
>>   #define __smp_mb__before_atomic()      do { } while (0)
>>   #define __smp_mb__after_atomic()       do { } while (0)
> 
>> +/* Writing to CR3 provides a full memory barrier in switch_mm(). */
>> +#define smp_mb__after_switch_mm()      do { } while (0)
>> +
>> #include <asm-generic/barrier.h>
> 
> IIUC, ppc already does smp_mb() in switch_mm.
> 
> Would it better to add the same macro which do nothing to pcc?\\

Does it ?

Based on arch/powerpc/include/asm/membarrier.h, it appears that
powerpc does _not_ have a guaranteed barrier in switch_mm():

static inline void membarrier_arch_switch_mm(struct mm_struct *prev,
                                              struct mm_struct *next,
                                              struct task_struct *tsk)
{
         /*
          * Only need the full barrier when switching between processes.
          * Barrier when switching from kernel to userspace is not
          * required here, given that it is implied by mmdrop(). Barrier
          * when switching from userspace to kernel is not needed after
          * store to rq->curr.
          */
         if (IS_ENABLED(CONFIG_SMP) &&
             likely(!(atomic_read(&next->membarrier_state) &
                      (MEMBARRIER_STATE_PRIVATE_EXPEDITED |
                       MEMBARRIER_STATE_GLOBAL_EXPEDITED)) || !prev))
                 return;

         /*
          * The membarrier system call requires a full memory barrier
          * after storing to rq->curr, before going back to user-space.
          */
         smp_mb();
}

AFAIU the barrier provided in powerpc switch_mm_irqs_off() is only in the
"new_on_cpu" case. Am I missing something ?

Thanks,

Mathieu

> 
> Thanks!
> 
-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com


  reply	other threads:[~2024-03-12 18:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-06 15:24 Mathieu Desnoyers
2024-03-11  8:45 ` Yeo Reum Yun
2024-03-12 18:07   ` Mathieu Desnoyers [this message]
2024-03-13  8:37     ` levi.yun

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=b7660de7-03ad-4d6c-b135-998d2cc0c80e@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=Catalin.Marinas@arm.com \
    --cc=Mark.Rutland@arm.com \
    --cc=YeoReum.Yun@arm.com \
    --cc=aaron.lu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=will@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

all inboxes | Powered by JetHome®