Message ID | 20210407202423.16022-1-mgorman@techsingularity.net |
---|---|
Headers | show |
Series | Use local_lock for pcp protection and reduce stat overhead | expand |
On Wed, Apr 07, 2021 at 09:24:12PM +0100, Mel Gorman wrote: > Why local_lock? PREEMPT_RT considers the following sequence to be unsafe > as documented in Documentation/locking/locktypes.rst > > local_irq_disable(); > raw_spin_lock(&lock); Almost, the above is actually OK on RT. The problematic one is: local_irq_disable(); spin_lock(&lock); That doesn't work on RT since spin_lock() turns into a PI-mutex which then obviously explodes if it tries to block with IRQs disabled. And it so happens, that's exactly the one at hand.
On Thu, Apr 08, 2021 at 12:56:01PM +0200, Peter Zijlstra wrote: > On Wed, Apr 07, 2021 at 09:24:12PM +0100, Mel Gorman wrote: > > Why local_lock? PREEMPT_RT considers the following sequence to be unsafe > > as documented in Documentation/locking/locktypes.rst > > > > local_irq_disable(); > > raw_spin_lock(&lock); > > Almost, the above is actually OK on RT. The problematic one is: > > local_irq_disable(); > spin_lock(&lock); > > That doesn't work on RT since spin_lock() turns into a PI-mutex which > then obviously explodes if it tries to block with IRQs disabled. > > And it so happens, that's exactly the one at hand. Ok, I completely messed up the leader because it was local_irq_disable() + spin_lock() that I was worried about. Once the series is complete, it is replated with local_lock_irq(&lock_lock) spin_lock(&lock); According to Documentation/locking/locktypes.rst, that should be safe. I'll rephrase the justification. -- Mel Gorman SUSE Labs
On 4/7/21 10:24 PM, Mel Gorman wrote: > @@ -6691,7 +6697,7 @@ static __meminit void zone_pcp_init(struct zone *zone) > * relies on the ability of the linker to provide the > * offset of a (static) per cpu variable into the per cpu area. > */ > - zone->pageset = &boot_pageset; > + zone->per_cpu_pageset = &boot_pageset; I don't see any &boot_zonestats assignment here in zone_pcp_init() or its caller(s), which seems strange, as zone_pcp_reset() does it. > zone->pageset_high = BOOT_PAGESET_HIGH; > zone->pageset_batch = BOOT_PAGESET_BATCH; > > @@ -8954,17 +8960,19 @@ void zone_pcp_reset(struct zone *zone) > { > unsigned long flags; > int cpu; > - struct per_cpu_pageset *pset; > + struct per_cpu_zonestat *pzstats; > > /* avoid races with drain_pages() */ > local_irq_save(flags); > - if (zone->pageset != &boot_pageset) { > + if (zone->per_cpu_pageset != &boot_pageset) { > for_each_online_cpu(cpu) { > - pset = per_cpu_ptr(zone->pageset, cpu); > - drain_zonestat(zone, pset); > + pzstats = per_cpu_ptr(zone->per_cpu_zonestats, cpu); > + drain_zonestat(zone, pzstats); > } > - free_percpu(zone->pageset); > - zone->pageset = &boot_pageset; > + free_percpu(zone->per_cpu_pageset); > + free_percpu(zone->per_cpu_zonestats); > + zone->per_cpu_pageset = &boot_pageset; > + zone->per_cpu_zonestats = &boot_zonestats; ^ here > } > local_irq_restore(flags); > }
On Mon, Apr 12, 2021 at 07:43:18PM +0200, Vlastimil Babka wrote: > On 4/7/21 10:24 PM, Mel Gorman wrote: > > @@ -6691,7 +6697,7 @@ static __meminit void zone_pcp_init(struct zone *zone) > > * relies on the ability of the linker to provide the > > * offset of a (static) per cpu variable into the per cpu area. > > */ > > - zone->pageset = &boot_pageset; > > + zone->per_cpu_pageset = &boot_pageset; > > I don't see any &boot_zonestats assignment here in zone_pcp_init() or its > caller(s), which seems strange, as zone_pcp_reset() does it. > Yes, it's required, well spotted! -- Mel Gorman SUSE Labs