Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752063AbdCSPDv (ORCPT ); Sun, 19 Mar 2017 11:03:51 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:35103 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751490AbdCSPDt (ORCPT ); Sun, 19 Mar 2017 11:03:49 -0400 Date: Sun, 19 Mar 2017 23:03:45 +0800 From: Wei Yang To: Michal Hocko Cc: Wei Yang , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: use BITS_PER_LONG to unify the definition in page->flags Message-ID: <20170319150345.GA34657@WeideMacBook-Pro.local> Reply-To: Wei Yang References: <20170318003914.24839-1-richard.weiyang@gmail.com> <20170319143012.GB12414@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0F1p//8PRICkK4MW" Content-Disposition: inline In-Reply-To: <20170319143012.GB12414@dhcp22.suse.cz> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2733 Lines: 81 --0F1p//8PRICkK4MW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Mar 19, 2017 at 10:30:13AM -0400, Michal Hocko wrote: >On Sat 18-03-17 08:39:14, Wei Yang wrote: >> The field page->flags is defined as unsigned long and is divided into >> several parts to store different information of the page, like section, >> node, zone. Which means all parts must sit in the one "unsigned >> long". >>=20 >> BITS_PER_LONG is used in several places to ensure this applies. >>=20 >> #if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > BITS_PER_LONG - NR_PAGE= FLAGS >> #if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT <=3D BITS_PER_LONG - NR_P= AGEFLAGS >> #if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT+LAST_CPUPID_SHIFT <=3D BI= TS_PER_LONG - NR_PAGEFLAGS >>=20 >> While we use "sizeof(unsigned long) * 8" in the definition of >> SECTIONS_PGOFF >>=20 >> #define SECTIONS_PGOFF ((sizeof(unsigned long)*8) - SECTIONS= _WIDTH) >>=20 >> This may not be that obvious for audience to catch the point. >>=20 >> This patch replaces the "sizeof(unsigned long) * 8" with BITS_PER_LONG to >> make all this consistent. > >I am not really sure this is an improvement. page::flags is unsigned >long nad the current code reflects that type. > Hi, Michal Glad to hear from you. I think the purpose of definition BITS_PER_LONG is more easily to let audie= nce know it is the number of bits of type long. If it has no improvement, we do= n't need to define a specific macro . And as you could see, several related macros use BITS_PER_LONG in their definition. After this change, all of them will have a consistent definitio= n. After this change, code looks more neat :-) So it looks more reasonable to use this. --=20 Wei Yang Help you, Help me --0F1p//8PRICkK4MW Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYzp3RAAoJEKcLNpZP5cTdxbYP/RpUbx65gjcOMCdXuvTtxh8O IXG/61Xeeiez8KkagRQ5Wo4kQxTTf2UNjJ5utFnC98GBCzFRXZe6P8/t1T+JcbYG ULcl0UoSsoz+Xxhj9RGAnRMPg1Gz6ZosboDRysDwkZAti3fIX+yR9nOJZxlxZG3M EP3cIRF4mGWc9otfYG15Kb5PIpE88HSlFc+mUC9sqAeMPCE714+bKooZeKh7YamG EdjCUcxRevEcUq7qbFQjEx8CDszkGNTrEp8O6KYvF+cF1um3FprGH+AxXuD6tGer Ej/R7udlzZKIUgD+Xrx/jIc8XVPBV4qXa++H91wzFrwiDe8CnXfLiW57iNZCAzif XPKtl8pObY3FU/+pXh5TeMnKboQKy4sqOCszYqqKN+vfS/z7/Jw4RgGg+3/Fha1w nRu48eWKn+lEhBCi+MDi+pyqOYnwmMtbCV9hPXwsy4+1afCr7eH2puj+XeSK6XbS DSCAjZnDEU5rxL+YbHsW6hjD7WdxDHYVNIee73W1D5cdmBst5iCiSPjjrbs3nlUl cS0YnHgIxEW6Efjo3LapRz3knJyJAMaGCsXPCoxc6TLqwUFMR4wBdcy4cgASEEjB wWg5rFamHrmpP1YVAs56lYWDYj22D0nvJ4+ZLZuh0oYna3jt3XxeJ4vxn3Xv4KN+ 8UxBP9JM+uBMUtqrhvMw =TLID -----END PGP SIGNATURE----- --0F1p//8PRICkK4MW--