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=-17.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 83B7DC4320A for ; Thu, 2 Sep 2021 12:45:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E1CCC61101 for ; Thu, 2 Sep 2021 12:45:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E1CCC61101 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 210C06B006C; Thu, 2 Sep 2021 08:45:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C0B88D0001; Thu, 2 Sep 2021 08:45:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0616D6B0072; Thu, 2 Sep 2021 08:45:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0135.hostedemail.com [216.40.44.135]) by kanga.kvack.org (Postfix) with ESMTP id E833D6B006C for ; Thu, 2 Sep 2021 08:45:56 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 80FDD824C447 for ; Thu, 2 Sep 2021 12:45:56 +0000 (UTC) X-FDA: 78542605512.29.094CD8E Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf01.hostedemail.com (Postfix) with ESMTP id 7338A50420F5 for ; Thu, 2 Sep 2021 12:45:55 +0000 (UTC) Received: from dggeme703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4H0gY02qcjzbkW4; Thu, 2 Sep 2021 20:41:56 +0800 (CST) Received: from [10.174.178.75] (10.174.178.75) by dggeme703-chm.china.huawei.com (10.1.199.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Thu, 2 Sep 2021 20:45:51 +0800 Subject: Re: [PATCH v2 5/5] mm/page_alloc.c: avoid allocating highmem pages via alloc_pages_exact[_nid] To: David Hildenbrand , CC: , , , , , References: <20210902121242.41607-1-linmiaohe@huawei.com> <20210902121242.41607-6-linmiaohe@huawei.com> <1ef3dc5d-7eb9-90a5-afbf-f551afcf7d8b@redhat.com> From: Miaohe Lin Message-ID: <0a14f77f-2242-e3e3-611b-6d23fdf51756@huawei.com> Date: Thu, 2 Sep 2021 20:45:51 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <1ef3dc5d-7eb9-90a5-afbf-f551afcf7d8b@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US X-Originating-IP: [10.174.178.75] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggeme703-chm.china.huawei.com (10.1.199.99) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 7338A50420F5 Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam01 X-Stat-Signature: pcj4oucf3q8yz1j4px8rq38qy56ezaoy X-HE-Tag: 1630586755-659198 Content-Transfer-Encoding: quoted-printable 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 2021/9/2 20:16, David Hildenbrand wrote: > On 02.09.21 14:12, Miaohe Lin wrote: >> Don't use with __GFP_HIGHMEM because page_address() cannot represent >> highmem pages without kmap(). Newly allocated pages would leak as >> page_address() will return NULL for highmem pages here. But It works >> now because the callers do not specify __GFP_HIGHMEM now. >> >> Signed-off-by: Miaohe Lin >> --- >> =C2=A0 mm/page_alloc.c | 8 ++++---- >> =C2=A0 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >> index 9c09dcb24149..e1d0e27d005a 100644 >> --- a/mm/page_alloc.c >> +++ b/mm/page_alloc.c >> @@ -5614,8 +5614,8 @@ void *alloc_pages_exact(size_t size, gfp_t gfp_m= ask) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned int order =3D get_order(size); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned long addr; >> =C2=A0 -=C2=A0=C2=A0=C2=A0 if (WARN_ON_ONCE(gfp_mask & __GFP_COMP)) >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gfp_mask &=3D ~__GFP_COMP; >> +=C2=A0=C2=A0=C2=A0 if (WARN_ON_ONCE(gfp_mask & (__GFP_COMP | __GFP_HI= GHMEM))) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gfp_mask &=3D ~(__GFP_COMP= | __GFP_HIGHMEM); >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 addr =3D __get_free_pages(gfp_ma= sk, order); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return make_alloc_exact(addr, order, si= ze); >> @@ -5639,8 +5639,8 @@ void * __meminit alloc_pages_exact_nid(int nid, = size_t size, gfp_t gfp_mask) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned int order =3D get_order(size); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct page *p; >> =C2=A0 -=C2=A0=C2=A0=C2=A0 if (WARN_ON_ONCE(gfp_mask & __GFP_COMP)) >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gfp_mask &=3D ~__GFP_COMP; >> +=C2=A0=C2=A0=C2=A0 if (WARN_ON_ONCE(gfp_mask & (__GFP_COMP | __GFP_HI= GHMEM))) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gfp_mask &=3D ~(__GFP_COMP= | __GFP_HIGHMEM); >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 p =3D alloc_pages_node(nid, gfp_= mask, order); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!p) >> >=20 > Ideally we would convert this WARN_ON_ONCE() to pr_warn_once(), but I g= uess this really never ever happens on a production system and would get = caught early while testing. >=20 This patch is mainly intended to make it clear that we simply can't call alloc_pages_exact[_nid] with GFP_HIGHMEM. So this warning would never eve= r happens. > Reviewed-by: David Hildenbrand >=20 Many thanks for your review and reply.