Received: by 10.223.176.46 with SMTP id f43csp629596wra; Thu, 18 Jan 2018 23:10:13 -0800 (PST) X-Google-Smtp-Source: ACJfBouAU2jmyLi07D81EoZ7COGCAuMVA0MOa9BVICQtyNgW8FSiCDhyoKgtMwT9MG7GFztySNbf X-Received: by 10.101.98.207 with SMTP id m15mr39193437pgv.67.1516345812964; Thu, 18 Jan 2018 23:10:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516345812; cv=none; d=google.com; s=arc-20160816; b=mHi8EA5Yd4uX3jAAK7LMkJ/DA3zDaL6m4DDv7hC33KX1UwzQRQWNnq0SFrDhn2jPm8 smbIvScUJ6rfJcibSVv6XBK8XpOmbvuc1ENavNvOivehpKSYmHSSSTlkOtPliRWZzaWM yLFIn0zdzkqmDPtkhHD+BAryP4PSuCm2xnjrZe7UxVkW/kqAR8FdKpR4Golyv50UMfMR qO+TKfnoI0aptuq5EBkmw4fWJj29nSbHqSYx+OXK50sblT95sYduCGFHSIh2y4GryKn+ YUJjt7HedV8LYN8HjWJs57l8qvXPvawVjDUw5redeEfYrTXNzX6pjPqc85xGLf6AvqCo Y63g== 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 :organization:message-id:subject:cc:to:from:date :arc-authentication-results; bh=dpIv46KlltyPPaZeobDhRVWozwfg7V+1ZbUCutwhIR0=; b=RodPo/cUJLSNJuRf8cTvvpPvERzZ2pa9/mlXXWNQE0MbqFuK89ebp63iq6yF9mLTST Hq/X0arBLNdWlfPalH73cGxVVdcz1DUmH8OIvXF82njQDKs6ZYPOdeRWQxH3McVeziCr rHoEbhKUxWH9ahid5x3UxPhJ2fF+Nn0Z5QIB3xgSuQK1Zzv2+ZD3pK+Q/Hu4dK9QyiU6 iWkcnjmxJ13tuxJ2E4GhRBkpwEIbwHJdZa+J6WLQ8AMGqxyLjOgu1sGyWV0pfOssHESE 0hzkAe39P7+mN75CD5LrYkzWLWbtVBT0LA0GDF/OXpqTIiP8f4FQRVGoQfq80JPCGfiA qkCw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17si7853670pge.478.2018.01.18.23.09.58; Thu, 18 Jan 2018 23:10:12 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754263AbeASHJ3 (ORCPT + 99 others); Fri, 19 Jan 2018 02:09:29 -0500 Received: from smtp2.provo.novell.com ([137.65.250.81]:41904 "EHLO smtp2.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750757AbeASHJZ (ORCPT ); Fri, 19 Jan 2018 02:09:25 -0500 Received: from ezekiel.suse.cz (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Fri, 19 Jan 2018 00:09:13 -0700 Date: Fri, 19 Jan 2018 08:09:08 +0100 From: Petr Tesarik To: linux-mm@kvack.org, Andrew Morton , Michal Hocko , Vlastimil Babka Cc: linux-kernel@vger.kernel.org, Mel Gorman , Johannes Weiner , Kemi Wang , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov Subject: [PATCH] Fix explanation of lower bits in the SPARSEMEM mem_map pointer Message-ID: <20180119080908.3a662e6f@ezekiel.suse.cz> Organization: SUSE Linux X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The comment is confusing. On the one hand, it refers to 32-bit alignment (struct page alignment on 32-bit platforms), but this would only guarantee that the 2 lowest bits must be zero. On the other hand, it claims that at least 3 bits are available, and 3 bits are actually used. This is not broken, because there is a stronger alignment guarantee, just less obvious. Let's fix the comment to make it clear how many bits are available and why. Signed-off-by: Petr Tesarik --- include/linux/mmzone.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 67f2e3c38939..7522a6987595 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1166,8 +1166,16 @@ extern unsigned long usemap_size(void); /* * We use the lower bits of the mem_map pointer to store - * a little bit of information. There should be at least - * 3 bits here due to 32-bit alignment. + * a little bit of information. The pointer is calculated + * as mem_map - section_nr_to_pfn(pnum). The result is + * aligned to the minimum alignment of the two values: + * 1. All mem_map arrays are page-aligned. + * 2. section_nr_to_pfn() always clears PFN_SECTION_SHIFT + * lowest bits. PFN_SECTION_SHIFT is arch-specific + * (equal SECTION_SIZE_BITS - PAGE_SHIFT), and the + * worst combination is powerpc with 256k pages, + * which results in PFN_SECTION_SHIFT equal 6. + * To sum it up, at least 6 bits are available. */ #define SECTION_MARKED_PRESENT (1UL<<0) #define SECTION_HAS_MEM_MAP (1UL<<1) -- 2.13.6