Re: [PATCH] mm: simplify node/zone name printing

From: Sergey Senozhatsky
Date: Mon Dec 19 2016 - 02:32:41 EST


Hello,

On (12/19/16 08:00), Vlastimil Babka wrote:
[..]
> > @@ -4421,7 +4421,6 @@ void show_free_areas(unsigned int filter)
> > printk("lowmem_reserve[]:");
> > for (i = 0; i < MAX_NR_ZONES; i++)
> > printk(KERN_CONT " %ld", zone->lowmem_reserve[i]);
> > - printk(KERN_CONT "\n");
>
> So there's really no functional difference between terminating line
> explicitly with "\n", and doing a followup printk() without KERN_CONT?
> I agree that a KERN_CONT line just to print "\n" is ugly, just want to
> be sure we are really safe without it, considering how KERN_CONT has
> been recently changed etc.

depending on what will follow. if another KERN_CONT printk then
without this explicit '\n' printk may assume that we are still
in cont printing; if something else -- printk should flush.

kernel/printk/printk.c

/*
* If an earlier line was buffered, and we're a continuation
* write from the same process, try to add it to the buffer.
*/
if (cont.len) {
if (cont.owner == current && (lflags & LOG_CONT)) {
if (cont_add(facility, level, lflags, text, text_len))
return text_len;
}
/* Otherwise, make sure it's flushed */
cont_flush();
}


as far as I can tell, now for_each_populated_zone() iterations are
split by non-CONT printk() from show_zone_node(), which previously
has been printk(KERN_CONT "%s: ", zone->name), so pr_cont(\n)
between iterations was important, but now that non-CONT printk()
should do the trick. it's _a bit_ hacky, though.

-ss

> > }
> >
> > for_each_populated_zone(zone) {
> > @@ -4431,8 +4430,7 @@ void show_free_areas(unsigned int filter)
> >
> > if (skip_free_areas_node(filter, zone_to_nid(zone)))
> > continue;
> > - show_node(zone);
> > - printk(KERN_CONT "%s: ", zone->name);
> > + show_zone_node(zone);
> >
> > spin_lock_irqsave(&zone->lock, flags);