Re: [ltt-dev] [PATCH] Fix dirty page accounting in redirty_page_for_writepage()

Christoph Lameter
2009-05-02T03:10:41Z

On Fri, 1 May 2009, Mathieu Desnoyers wrote:

> Then, if I understand you correctly, you propose :
>
> void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
> {
> ... assuming p references percpu "u8" counters ...
> u8 p_new;
>
> p_new = percpu_add_return(p, 1);
>
> if (unlikely(!(p_new & pcp->stat_threshold_mask)))
> zone_page_state_add(pcp->stat_threshold, zone, item);
> }
>
> void inc_zone_state(struct zone *zone, enum zone_stat_item item)
> {
> ... assuming p references percpu "u8" counters ...
> u8 p_new;
>
> p_new = percpu_add_return_irqsafe(p, 1);
>
> if (unlikely(!(p_new & pcp->stat_threshold_mask)))
> zone_page_state_add(pcp->stat_threshold, zone, item);
> }
>
> (therefore opting for code duplication)
>
> Am I correct ?

Well __inc_zone_state is fine by itself. inc_zone_state will currently
disable irqs. But we can do it your way and duplicate the code.

> void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
> {
> ... assuming p references percpu "u8" counters ...
> u8 p_new;
>
> p_new = __percpu_add_return_irqsafe(p, 1);
>
> if (unlikely(!(p_new & pcp->stat_threshold_mask)))
> zone_page_state_add(pcp->stat_threshold, zone, item);
> }
>
> void inc_zone_state(struct zone *zone, enum zone_stat_item item)
> {
> unsigned long flags;
>
> percpu_local_irqsave(flags);
> __inc_zone_state(zone, item);
> percpu_local_irqrestore(flags);
> }
>
> Which is more compact and does not duplicate code.

This is almost like the current code. But lets avoid percpu_local_irqs
etc if we can.