From patchwork Wed Jul 7 04:55:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12361751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 339B8C07E95 for ; Wed, 7 Jul 2021 04:56:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AA8E761CB3 for ; Wed, 7 Jul 2021 04:56:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA8E761CB3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 30D106B0036; Wed, 7 Jul 2021 00:56:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2BC616B005D; Wed, 7 Jul 2021 00:56:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15D146B006C; Wed, 7 Jul 2021 00:56:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0003.hostedemail.com [216.40.44.3]) by kanga.kvack.org (Postfix) with ESMTP id E02316B0036 for ; Wed, 7 Jul 2021 00:56:10 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3BADD250B2 for ; Wed, 7 Jul 2021 04:56:10 +0000 (UTC) X-FDA: 78334580100.05.D291921 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf11.hostedemail.com (Postfix) with ESMTP id 903C0F0000BD for ; Wed, 7 Jul 2021 04:56:09 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1625633768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=8m+HNzVq0gzAYARME3oTYtiO24eMnzxPfdq9z6WDvVY=; b=BS2cpujjXcxcQM/8jKe/Ly7M0+wg8SlEMO91M2i6vErlvqcA0xhIHVXSRQUIF0Jw8aC3/W MSDYWWMQ4aEVXcrFaVukADMvYyYxH54G1bPu6XAsJZcXiduWrWKoRuX39UuGEJnmcVwyCl bM6pOavQAX1QMRfUvDW+nmvhmt3WDpo= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Dan Williams , David Hildenbrand , Oscar Salvador , Wang Wensheng , rui.xiang@huawei.com, k-hagio-ab@nec.com, Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v2] mm/sparse: set SECTION_NID_SHIFT to 6 Date: Wed, 7 Jul 2021 13:55:48 +0900 Message-Id: <20210707045548.810271-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: naoya.horiguchi@linux.dev X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 903C0F0000BD X-Stat-Signature: zurzqxb5ygokpmxr9f9emxcxynouyy19 Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=BS2cpujj; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf11.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev X-HE-Tag: 1625633769-20194 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Naoya Horiguchi Currently SECTION_NID_SHIFT is set to 3, which is incorrect because bit 3 and 4 can be overlapped by sub-field for early NID, and can be unexpectedly set on NUMA systems. There are a few non-critical issues related to this: - Having SECTION_TAINT_ZONE_DEVICE set for wrong sections forces pfn_to_online_page() through the slow path, but doesn't actually break the kernel. - A kdump generation tool like makedumpfile uses this field to calculate the physical address to read. So wrong bits can make the tool access to wrong address and fail to create kdump. This can be avoided by the tool, so it's not critical. To fix it, set SECTION_NID_SHIFT to 6 which is the minimum number of available bits of section flag field. Fixes: 1f90a3477df3 ("mm: teach pfn_to_online_page() about ZONE_DEVICE section collisions") Reported-by: Kazuhito Hagio Suggested-by: Dan Williams Signed-off-by: Naoya Horiguchi Acked-by: David Hildenbrand --- include/linux/mmzone.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git v5.13/include/linux/mmzone.h v5.13_patched/include/linux/mmzone.h index 0d53eba1c383..a6829b652d79 100644 --- v5.13/include/linux/mmzone.h +++ v5.13_patched/include/linux/mmzone.h @@ -1344,7 +1344,7 @@ extern size_t mem_section_usage_size(void); #define SECTION_TAINT_ZONE_DEVICE (1UL<<4) #define SECTION_MAP_LAST_BIT (1UL<<5) #define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1)) -#define SECTION_NID_SHIFT 3 +#define SECTION_NID_SHIFT 6 static inline struct page *__section_mem_map_addr(struct mem_section *section) {