From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,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 DD31CC4361B for ; Fri, 18 Dec 2020 09:06:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 672EE23A5B for ; Fri, 18 Dec 2020 09:06:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 672EE23A5B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EC7476B005D; Fri, 18 Dec 2020 04:06:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E75D96B0068; Fri, 18 Dec 2020 04:06:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D64CB6B006C; Fri, 18 Dec 2020 04:06:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0223.hostedemail.com [216.40.44.223]) by kanga.kvack.org (Postfix) with ESMTP id BBBB36B005D for ; Fri, 18 Dec 2020 04:06:39 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 74135180FA15B for ; Fri, 18 Dec 2020 09:06:39 +0000 (UTC) X-FDA: 77605822518.04.cart63_1b0438c2743c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 5767B80124DF for ; Fri, 18 Dec 2020 09:06:39 +0000 (UTC) X-HE-Tag: cart63_1b0438c2743c X-Filterd-Recvd-Size: 3274 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Dec 2020 09:06:38 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5572DABC6; Fri, 18 Dec 2020 09:06:37 +0000 (UTC) Date: Fri, 18 Dec 2020 10:06:31 +0100 From: Oscar Salvador To: Muchun Song Cc: corbet@lwn.net, mike.kravetz@oracle.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, paulmck@kernel.org, mchehab+huawei@kernel.org, pawan.kumar.gupta@linux.intel.com, rdunlap@infradead.org, oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de, almasrymina@google.com, rientjes@google.com, willy@infradead.org, mhocko@suse.com, song.bao.hua@hisilicon.com, david@redhat.com, naoya.horiguchi@nec.com, duanxiongchun@bytedance.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v10 10/11] mm/hugetlb: Gather discrete indexes of tail page Message-ID: <20201218090631.GA3623@localhost.localdomain> References: <20201217121303.13386-1-songmuchun@bytedance.com> <20201217121303.13386-11-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201217121303.13386-11-songmuchun@bytedance.com> 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: On Thu, Dec 17, 2020 at 08:13:02PM +0800, Muchun Song wrote: > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 6c02f49959fd..78dd88dda857 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1360,7 +1360,7 @@ static inline void hwpoison_subpage_deliver(struct hstate *h, struct page *head) > if (!PageHWPoison(head) || !free_vmemmap_pages_per_hpage(h)) > return; > > - page = head + page_private(head + 4); > + page = head + page_private(head + SUBPAGE_INDEX_HWPOISON); > > /* > * Move PageHWPoison flag from head page to the raw error page, > @@ -1379,7 +1379,7 @@ static inline void hwpoison_subpage_set(struct hstate *h, struct page *head, > return; > > if (free_vmemmap_pages_per_hpage(h)) { > - set_page_private(head + 4, page - head); > + set_page_private(head + SUBPAGE_INDEX_HWPOISON, page - head); Ok, I was too eager here. If CONFIG_HUGETLB_PAGE_FREE_VMEMMAP is not set for whatever reason (e.g: CONFIG_MEMORY_HOTREMOVE is disabled), when you convert "+4" to its index (SUBPAGE_INDEX_HWPOISON), this will no longer build since we only define SUBPAGE_INDEX_HWPOISON when the config option CONFIG_HUGETLB_PAGE_FREE_VMEMMAP is set. Different things can be done to fix this: e.g: - Define a two different hwpoison_subpage_{deliver,set} and have them under #ifdef CONFIG_HUGETLB_PAGE_FREE_VMEMMAP ... #else ... #endif - Work it around as is with IS_ENABLED(CONFIG_HUGETLB_... - Have a common entry and decide depending on whether the config is enabled. I guess option #1 might be cleaner. -- Oscar Salvador SUSE L3