Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759644AbbLCMho (ORCPT ); Thu, 3 Dec 2015 07:37:44 -0500 Received: from mail-lb0-f174.google.com ([209.85.217.174]:32944 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751209AbbLCMhn (ORCPT ); Thu, 3 Dec 2015 07:37:43 -0500 From: Rasmus Villemoes To: Vlastimil Babka Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Joonsoo Kim , Minchan Kim , Sasha Levin , "Kirill A. Shutemov" , Mel Gorman , Michal Hocko Subject: Re: [PATCH 1/2] mm, printk: introduce new format string for flags Organization: D03 References: <20151125143010.GI27283@dhcp22.suse.cz> <1448899821-9671-1-git-send-email-vbabka@suse.cz> <87io4hi06n.fsf@rasmusvillemoes.dk> <565F55E6.6080201@suse.cz> X-Hashcash: 1:20:151203:linux-kernel@vger.kernel.org::oDAmiishGAgYY5U5:0000000000000000000000000000000000F1W X-Hashcash: 1:20:151203:vbabka@suse.cz::Go2wqmMeSI+YC0Ru:00016Qh X-Hashcash: 1:20:151203:mhocko@suse.cz::XcCDMAHqu9/2rrCM:0001DHU X-Hashcash: 1:20:151203:minchan@kernel.org::IXOHce5Wq5Db7yKD:00000000000000000000000000000000000000000003Idr X-Hashcash: 1:20:151203:linux-mm@kvack.org::3jzm6hamShD5FvQh:00000000000000000000000000000000000000000003qg6 X-Hashcash: 1:20:151203:iamjoonsoo.kim@lge.com::fNNP5YntzPyFVmJF:0000000000000000000000000000000000000003sQg X-Hashcash: 1:20:151203:akpm@linux-foundation.org::53OBIoaMAy9do4Ac:000000000000000000000000000000000000ARtd X-Hashcash: 1:20:151203:kirill.shutemov@linux.intel.com::9BHcbAeue5RcTefQ:000000000000000000000000000000BLxF X-Hashcash: 1:20:151203:mgorman@suse.de::jja/fafVNL5u4pXl:00Afmc X-Hashcash: 1:20:151203:sasha.levin@oracle.com::ZbfEGr1z/Kus4+sd:000000000000000000000000000000000000000AdmE Date: Thu, 03 Dec 2015 13:37:39 +0100 In-Reply-To: <565F55E6.6080201@suse.cz> (Vlastimil Babka's message of "Wed, 2 Dec 2015 21:34:46 +0100") Message-ID: <87mvtrpv1o.fsf@rasmusvillemoes.dk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2552 Lines: 67 On Wed, Dec 02 2015, Vlastimil Babka wrote: >> [where I've assumed that the trace_print_flags array is terminated with >> an entry with 0 mask. Passing its length is also possible, but maybe a >> little awkward if the arrays are defined in mm/ and contents depend on >> .config.] ... > >> Rasmus > > Zero-terminated array is a good idea to get rid of the ARRAY_SIZE with helpers > needing to live in the same .c file etc. > > But if I were to keep the array definitions in mm/debug.c with declarations > (which don't know the size yet) in e.g. (which lib/vsnprintf.c > would include so that format_flags() can reference them, is there a more elegant > way than the one below? > > --- a/include/linux/mmdebug.h > +++ b/include/linux/mmdebug.h > @@ -7,6 +7,9 @@ > struct page; > struct vm_area_struct; > struct mm_struct; > +struct trace_print_flags; // can't include trace_events.h here > + > +extern const struct trace_print_flags *pageflag_names; > > extern void dump_page(struct page *page, const char *reason); > extern void dump_page_badflags(struct page *page, const char *reason, > diff --git a/mm/debug.c b/mm/debug.c > index a092111920e7..1cbc60544b87 100644 > --- a/mm/debug.c > +++ b/mm/debug.c > @@ -23,7 +23,7 @@ char *migrate_reason_names[MR_TYPES] = { > "cma", > }; > > -static const struct trace_print_flags pageflag_names[] = { > +const struct trace_print_flags __pageflag_names[] = { > {1UL << PG_locked, "locked" }, > {1UL << PG_error, "error" }, > {1UL << PG_referenced, "referenced" }, > @@ -59,6 +59,8 @@ static const struct trace_print_flags pageflag_names[] = { > #endif > }; > > +const struct trace_print_flags *pageflag_names = &__pageflag_names[0]; Ugh. I think it would be better if either the definition of struct trace_print_flags is moved somewhere where everybody can see it or to make our own identical type definition. For now I'd go with the latter, also since this doesn't really have anything to do with the tracing subsystem. Then just declare the array in the header extern const struct print_flags pageflag_names[]; (If you do the extra indirection thing, __pageflag_names could still be static, and it would be best to declare the pointer itself const as well, but I'd rather we don't go that way.) Rasmus -- 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/