* One question about API cpumask_setall() @ 2026-07-28 8:16 Bibo Mao 2026-07-29 1:55 ` Yury Norov 0 siblings, 1 reply; 7+ messages in thread From: Bibo Mao @ 2026-07-28 8:16 UTC (permalink / raw) To: Yury Norov; +Cc: Rasmus Villemoes, linux-kernel Hi, I am preparing to use API cpumask_setall() for TLB flush on LoongArch KVM side. There are cpumask_test_and_clear_cpu/cpumask_setall() APIs, it seems that API cpumask_setall() does not support atomic operation. Do you think it is reasonable to add new API similar with cpumask_setall() which supports atomic operation? Regards Bibo Mao ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: One question about API cpumask_setall() 2026-07-28 8:16 One question about API cpumask_setall() Bibo Mao @ 2026-07-29 1:55 ` Yury Norov 2026-07-29 2:13 ` Bibo Mao 0 siblings, 1 reply; 7+ messages in thread From: Yury Norov @ 2026-07-29 1:55 UTC (permalink / raw) To: Bibo Mao; +Cc: Yury Norov, Rasmus Villemoes, linux-kernel On Tue, Jul 28, 2026 at 04:16:27PM +0800, Bibo Mao wrote: > Hi, > > I am preparing to use API cpumask_setall() for TLB flush on LoongArch KVM > side. There are cpumask_test_and_clear_cpu/cpumask_setall() APIs, it seems > that API cpumask_setall() does not support atomic operation. > > Do you think it is reasonable to add new API similar with cpumask_setall() > which supports atomic operation? Maybe reasonable, but it's impossible. cpumask is a bitmap, which in turn is an array of unsigned longs. There's no atomic operations on arrays. Thanks, Yury ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: One question about API cpumask_setall() 2026-07-29 1:55 ` Yury Norov @ 2026-07-29 2:13 ` Bibo Mao 2026-07-29 17:57 ` Yury Norov 0 siblings, 1 reply; 7+ messages in thread From: Bibo Mao @ 2026-07-29 2:13 UTC (permalink / raw) To: Yury Norov; +Cc: Yury Norov, Rasmus Villemoes, linux-kernel On 2026/7/29 上午9:55, Yury Norov wrote: > On Tue, Jul 28, 2026 at 04:16:27PM +0800, Bibo Mao wrote: >> Hi, >> >> I am preparing to use API cpumask_setall() for TLB flush on LoongArch KVM >> side. There are cpumask_test_and_clear_cpu/cpumask_setall() APIs, it seems >> that API cpumask_setall() does not support atomic operation. >> >> Do you think it is reasonable to add new API similar with cpumask_setall() >> which supports atomic operation? > > Maybe reasonable, but it's impossible. cpumask is a bitmap, which in > turn is an array of unsigned longs. There's no atomic operations on > arrays. It should be workable with atomic operation on unsigned long, rather than the array of unsigned longs, the API cpumask_test_and_clear_cpu is atomic operation on unsigned long also. Is it ok to use smp_store_mb() to fill the bitmap with the similar API cpumask_setall()? where xchg() is used in smp_store_mb() wrapper instead. Regards Bibo Mao > > Thanks, > Yury > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: One question about API cpumask_setall() 2026-07-29 2:13 ` Bibo Mao @ 2026-07-29 17:57 ` Yury Norov 2026-07-30 6:41 ` Bibo Mao 0 siblings, 1 reply; 7+ messages in thread From: Yury Norov @ 2026-07-29 17:57 UTC (permalink / raw) To: Bibo Mao; +Cc: Yury Norov, Rasmus Villemoes, linux-kernel On Wed, Jul 29, 2026 at 10:13:56AM +0800, Bibo Mao wrote: > > > On 2026/7/29 上午9:55, Yury Norov wrote: > > On Tue, Jul 28, 2026 at 04:16:27PM +0800, Bibo Mao wrote: > > > Hi, > > > > > > I am preparing to use API cpumask_setall() for TLB flush on LoongArch KVM > > > side. There are cpumask_test_and_clear_cpu/cpumask_setall() APIs, it seems > > > that API cpumask_setall() does not support atomic operation. > > > > > > Do you think it is reasonable to add new API similar with cpumask_setall() > > > which supports atomic operation? > > > > Maybe reasonable, but it's impossible. cpumask is a bitmap, which in > > turn is an array of unsigned longs. There's no atomic operations on > > arrays. > It should be workable with atomic operation on unsigned long, rather than > the array of unsigned longs, the API cpumask_test_and_clear_cpu is atomic > operation on unsigned long also. No, cpumask_test_and_clear_cpu is atomic() operates on cpumask_t*, which is a pointer to unsigned long. > Is it ok to use smp_store_mb() to fill the bitmap with the similar API > cpumask_setall()? where xchg() is used in smp_store_mb() wrapper instead. If your bitmap is longer than 1 word, you'll have to issue 2 or more smp_store_mb()'s. Then, a series of atomic operations is not atomic itself. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: One question about API cpumask_setall() 2026-07-29 17:57 ` Yury Norov @ 2026-07-30 6:41 ` Bibo Mao 2026-08-03 21:51 ` Yury Norov 0 siblings, 1 reply; 7+ messages in thread From: Bibo Mao @ 2026-07-30 6:41 UTC (permalink / raw) To: Yury Norov; +Cc: Yury Norov, Rasmus Villemoes, linux-kernel On 2026/7/30 上午1:57, Yury Norov wrote: > On Wed, Jul 29, 2026 at 10:13:56AM +0800, Bibo Mao wrote: >> >> >> On 2026/7/29 上午9:55, Yury Norov wrote: >>> On Tue, Jul 28, 2026 at 04:16:27PM +0800, Bibo Mao wrote: >>>> Hi, >>>> >>>> I am preparing to use API cpumask_setall() for TLB flush on LoongArch KVM >>>> side. There are cpumask_test_and_clear_cpu/cpumask_setall() APIs, it seems >>>> that API cpumask_setall() does not support atomic operation. >>>> >>>> Do you think it is reasonable to add new API similar with cpumask_setall() >>>> which supports atomic operation? >>> >>> Maybe reasonable, but it's impossible. cpumask is a bitmap, which in >>> turn is an array of unsigned longs. There's no atomic operations on >>> arrays. >> It should be workable with atomic operation on unsigned long, rather than >> the array of unsigned longs, the API cpumask_test_and_clear_cpu is atomic >> operation on unsigned long also. > > No, cpumask_test_and_clear_cpu is atomic() operates on cpumask_t*, > which is a pointer to unsigned long. > >> Is it ok to use smp_store_mb() to fill the bitmap with the similar API >> cpumask_setall()? where xchg() is used in smp_store_mb() wrapper instead. > > If your bitmap is longer than 1 word, you'll have to issue 2 or more > smp_store_mb()'s. Then, a series of atomic operations is not atomic > itself. I understand what you say, the whole series of atomic operations is not atomic. My concern is whether cpumask_test_and_clear_cpu() operation on cpumask_t* will invalidate non-atomic write operation on another CPU. From MESI/MOSI protocol, this will not happen, only that order of write and atomic test_and_clear operation may be different. Regards Bibo Mao ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: One question about API cpumask_setall() 2026-07-30 6:41 ` Bibo Mao @ 2026-08-03 21:51 ` Yury Norov 2026-08-05 7:39 ` Bibo Mao 0 siblings, 1 reply; 7+ messages in thread From: Yury Norov @ 2026-08-03 21:51 UTC (permalink / raw) To: Bibo Mao; +Cc: Yury Norov, Rasmus Villemoes, linux-kernel On Thu, Jul 30, 2026 at 02:41:42PM +0800, Bibo Mao wrote: > > > On 2026/7/30 上午1:57, Yury Norov wrote: > > On Wed, Jul 29, 2026 at 10:13:56AM +0800, Bibo Mao wrote: > > > > > > > > > On 2026/7/29 上午9:55, Yury Norov wrote: > > > > On Tue, Jul 28, 2026 at 04:16:27PM +0800, Bibo Mao wrote: > > > > > Hi, > > > > > > > > > > I am preparing to use API cpumask_setall() for TLB flush on LoongArch KVM > > > > > side. There are cpumask_test_and_clear_cpu/cpumask_setall() APIs, it seems > > > > > that API cpumask_setall() does not support atomic operation. > > > > > > > > > > Do you think it is reasonable to add new API similar with cpumask_setall() > > > > > which supports atomic operation? > > > > > > > > Maybe reasonable, but it's impossible. cpumask is a bitmap, which in > > > > turn is an array of unsigned longs. There's no atomic operations on > > > > arrays. > > > It should be workable with atomic operation on unsigned long, rather than > > > the array of unsigned longs, the API cpumask_test_and_clear_cpu is atomic > > > operation on unsigned long also. > > > > No, cpumask_test_and_clear_cpu is atomic() operates on cpumask_t*, > > which is a pointer to unsigned long. > > > Is it ok to use smp_store_mb() to fill the bitmap with the similar API > > > cpumask_setall()? where xchg() is used in smp_store_mb() wrapper instead. > > > > If your bitmap is longer than 1 word, you'll have to issue 2 or more > > smp_store_mb()'s. Then, a series of atomic operations is not atomic > > itself. > I understand what you say, the whole series of atomic operations is not > atomic. > > My concern is whether cpumask_test_and_clear_cpu() operation on cpumask_t* > will invalidate non-atomic write operation on another CPU. From MESI/MOSI > protocol, this will not happen, only that order of write and atomic > test_and_clear operation may be different. You're changing the topic now. You asked about the atomic version of cpumask_setall(), and I've pointed that it's impossible. Now you're asking about invalidation of caches. I can't say for each and every architecture out there, and all their caching modes. If you need to run cpumask_setall() concurrently with cpumask_test_and_clear_cpu(), please use external locking mechanism. Thanks, Yury ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: One question about API cpumask_setall() 2026-08-03 21:51 ` Yury Norov @ 2026-08-05 7:39 ` Bibo Mao 0 siblings, 0 replies; 7+ messages in thread From: Bibo Mao @ 2026-08-05 7:39 UTC (permalink / raw) To: Yury Norov; +Cc: Yury Norov, Rasmus Villemoes, linux-kernel On 2026/8/4 上午5:51, Yury Norov wrote: > On Thu, Jul 30, 2026 at 02:41:42PM +0800, Bibo Mao wrote: >> >> >> On 2026/7/30 上午1:57, Yury Norov wrote: >>> On Wed, Jul 29, 2026 at 10:13:56AM +0800, Bibo Mao wrote: >>>> >>>> >>>> On 2026/7/29 上午9:55, Yury Norov wrote: >>>>> On Tue, Jul 28, 2026 at 04:16:27PM +0800, Bibo Mao wrote: >>>>>> Hi, >>>>>> >>>>>> I am preparing to use API cpumask_setall() for TLB flush on LoongArch KVM >>>>>> side. There are cpumask_test_and_clear_cpu/cpumask_setall() APIs, it seems >>>>>> that API cpumask_setall() does not support atomic operation. >>>>>> >>>>>> Do you think it is reasonable to add new API similar with cpumask_setall() >>>>>> which supports atomic operation? >>>>> >>>>> Maybe reasonable, but it's impossible. cpumask is a bitmap, which in >>>>> turn is an array of unsigned longs. There's no atomic operations on >>>>> arrays. >>>> It should be workable with atomic operation on unsigned long, rather than >>>> the array of unsigned longs, the API cpumask_test_and_clear_cpu is atomic >>>> operation on unsigned long also. >>> >>> No, cpumask_test_and_clear_cpu is atomic() operates on cpumask_t*, >>> which is a pointer to unsigned long. >>>> Is it ok to use smp_store_mb() to fill the bitmap with the similar API >>>> cpumask_setall()? where xchg() is used in smp_store_mb() wrapper instead. >>> >>> If your bitmap is longer than 1 word, you'll have to issue 2 or more >>> smp_store_mb()'s. Then, a series of atomic operations is not atomic >>> itself. >> I understand what you say, the whole series of atomic operations is not >> atomic. >> >> My concern is whether cpumask_test_and_clear_cpu() operation on cpumask_t* >> will invalidate non-atomic write operation on another CPU. From MESI/MOSI >> protocol, this will not happen, only that order of write and atomic >> test_and_clear operation may be different. > > You're changing the topic now. You asked about the atomic version of > cpumask_setall(), and I've pointed that it's impossible. It is my fault, I do not explain the context clearly. I need to run cpumask_setall() concurrently with cpumask_test_and_clear_cpu(), the first idea coming from me is atomic method. :( > > Now you're asking about invalidation of caches. I can't say for each > and every architecture out there, and all their caching modes. > > If you need to run cpumask_setall() concurrently with > cpumask_test_and_clear_cpu(), please use external locking mechanism. yes, locking mechanism is one method for the concurrent contention issue. And thanks for your help. Regards Bibo Mao > > Thanks, > Yury > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-08-05 7:40 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-07-28 8:16 One question about API cpumask_setall() Bibo Mao 2026-07-29 1:55 ` Yury Norov 2026-07-29 2:13 ` Bibo Mao 2026-07-29 17:57 ` Yury Norov 2026-07-30 6:41 ` Bibo Mao 2026-08-03 21:51 ` Yury Norov 2026-08-05 7:39 ` Bibo Mao
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.