Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4433817ybh; Tue, 6 Aug 2019 11:34:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/ELou9qt9i2gqn+jpUYeAS/q1Uie4vaybJdLoicI33HhWIVQEGfHrbsje0ZeTe4V559fT X-Received: by 2002:a17:90a:228b:: with SMTP id s11mr4439900pjc.23.1565116462672; Tue, 06 Aug 2019 11:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565116462; cv=none; d=google.com; s=arc-20160816; b=mRbc+T1W+3YQJ26HtkYReYRKs/qs9V7oQuXNZ04tcZvs1q/BufvPhM4FvLrA5LZJi8 QWK6yc8gp5KeF2fGYNZtJLQi+EEjO1g3VSERgo2ZU1S0bJeT2D6LYfhy3vtSeZ9GLaG9 uqViw/OG1QeFg8Uc+mzFC/9tztBTj9qveQoOIXvNwjJMF0FNtutFXh3of4NJO2R5Q0+b XjSUnKiyQJkyLDFfMdi3YSu9y3FS+E4TBS7aV5zIsXU+GSGr7QjYgPz80J6RcHh+o5Ld l5WhhQPzeTz9qKG3B6NL8EqZHqtqE6ubau2fMgRnPGG7TP8KDh8deUSA9t2CShxL+FK1 t0ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=Cm9hk9u0afn+ZjMDnzSZ+v/EgUHwNgOxDe/V4NqAJfw=; b=b29HDkZDThLXKWIf35SUSmBC5gf+Da+AwnajPK9wvEJWNK9V3zEC7y9uMoTd0s9n4q fgxUBBwt1UTeXveD9dYfm4KSqoaV/VoDtmNpdLZl1zrMZCZUfK7FSSikwHQrDZ8DzquC wiE6mT2btVDV7X8Gc03wJEgK3ZVZw0B91SDDeLCki2jLIE3Bx2ldDSYrfcVMOoBOEt72 cT26I4mjwUP3aYrJxFUG9+TRGidXEWa2aKl5mQISagTzSp6Ss7MSA5pxtP3Dg8I0q5dT UFk5mEQ/q1WFCYaf/Syq3wpiSZmwReKgAUIQDHjv6KrsSXYsPmJxzXhQ4uQ7TAbQf9F0 +xNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 91si44295286ply.196.2019.08.06.11.34.06; Tue, 06 Aug 2019 11:34:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732780AbfHFSdN (ORCPT + 99 others); Tue, 6 Aug 2019 14:33:13 -0400 Received: from mga04.intel.com ([192.55.52.120]:33316 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732489AbfHFSdM (ORCPT ); Tue, 6 Aug 2019 14:33:12 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Aug 2019 11:33:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,353,1559545200"; d="scan'208";a="168378909" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga008.jf.intel.com with ESMTP; 06 Aug 2019 11:33:12 -0700 Message-ID: <9a09db3d4827bc6bf49c4579d495d71015f2c5a6.camel@intel.com> Subject: Re: [PATCH V2] fork: Improve error message for corrupted page tables From: Sai Praneeth Prakhya To: Dave Hansen , linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Ingo Molnar , Vlastimil Babka , Peter Zijlstra , Andrew Morton , Anshuman Khandual Date: Tue, 06 Aug 2019 11:30:02 -0700 In-Reply-To: <73b77479-cdd2-6d53-14ae-25ec4c4c3d25@intel.com> References: <3ef8a340deb1c87b725d44edb163073e2b6eca5a.1565059496.git.sai.praneeth.prakhya@intel.com> <73b77479-cdd2-6d53-14ae-25ec4c4c3d25@intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5-0ubuntu0.18.10.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2019-08-06 at 09:30 -0700, Dave Hansen wrote: > On 8/5/19 8:05 PM, Sai Praneeth Prakhya wrote: > > +static const char * const resident_page_types[NR_MM_COUNTERS] = { > > + [MM_FILEPAGES] = "MM_FILEPAGES", > > + [MM_ANONPAGES] = "MM_ANONPAGES", > > + [MM_SWAPENTS] = "MM_SWAPENTS", > > + [MM_SHMEMPAGES] = "MM_SHMEMPAGES", > > +}; > > One trick to ensure that this gets updated if the names are ever > updated. You can do: > > #define NAMED_ARRAY_INDEX(x) [x] = __stringify(x), > > and > > static const char * const resident_page_types[NR_MM_COUNTERS] = { > NAMED_ARRAY_INDEX(MM_FILE_PAGES), > NAMED_ARRAY_INDEX(MM_SHMEMPAGES), > ... > }; Thanks for the suggestion Dave. I will add this in V3. Even with this, (if ever) anyone who changes the name of page types or adds an new entry would still need to update struct resident_page_types[]. So, I will add the comment as suggested by Vlastimil. > > That makes sure that any name changes make it into the strings. Then > stick a: > > BUILD_BUG_ON(NR_MM_COUNTERS != ARRAY_SIZE(resident_page_types)); > > somewhere. That makes sure that any new array indexes get a string > added in the array. Otherwise you get nice, early, compile-time errors. Sure! this sounds good and a small nit-bit :) For the BUILD_BUG_ON() to work, the definition of struct should be changed as below static const char * const resident_page_types[] = { ... } i.e. we should not specify the size of array. Regards, Sai