Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754117AbbFWIz2 (ORCPT ); Tue, 23 Jun 2015 04:55:28 -0400 Received: from rrzmta1.uni-regensburg.de ([194.94.155.51]:33665 "EHLO rrzmta1.uni-regensburg.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751692AbbFWIzW convert rfc822-to-8bit (ORCPT ); Tue, 23 Jun 2015 04:55:22 -0400 X-Greylist: delayed 445 seconds by postgrey-1.27 at vger.kernel.org; Tue, 23 Jun 2015 04:55:22 EDT Message-Id: <55893958020000A10001ADA2@gwsmtp1.uni-regensburg.de> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Beta Date: Tue, 23 Jun 2015 10:47:52 +0200 From: "Ulrich Windl" To: Subject: Formatting of /proc/meminfo Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8BIT Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1599 Lines: 43 Hi! My eyes just discovered this mis-alignment for x86_64 machines: --- # cat /proc/meminfo MemTotal: 81366016 kB MemFree: 36484504 kB Buffers: 1018764 kB Cached: 38230264 kB [...] VmallocTotal: 34359738367 kB VmallocUsed: 92792 kB VmallocChunk: 34359544432 kB HardwareCorrupted: 0 kB DirectMap4k: 132623356 kB DirectMap2M: 0 kB --- It seems the very big numbers for "Vmalloc" are OK, so I suggest to update the formatting. The current code looks like this (/usr/src/linux/fs/proc/meminfo.c): --- seq_printf(m, "MemTotal: %8lu kB\n" "MemFree: %8lu kB\n" "Buffers: %8lu kB\n" [...] --- So the field should be widened by three digits at least (%11lu kB). Maybe one could make the field width variable, depending on 32/64 bit (it would look like a waste on 32 bit platforms). Maybe the code would be friendlier to changes if there was one seq_printf() per value. Then one could use something like seq_printf(m, "%-16s%8lu kB\n", "MemTotal:", K(i.totalram)) instead, I guess... You could put the format (%-16s%8lu kB\n) in a constant also, allowing a change at one point to affect every item... Probably gcc will optimize the code anyway, so there won't be much difference regarding performance. Regards, Ulrich Windl -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/