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

Christoph Lameter cl at linux.com
Fri May 1 23:00:21 EDT 2009


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.




More information about the lttng-dev mailing list