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

From: Christoph Lameter
Date: Fri May 01 2009 - 23:10:42 EST


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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/