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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48F37C00A5A for ; Wed, 18 Jan 2023 01:56:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B48646B0071; Tue, 17 Jan 2023 20:56:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AF85E6B0072; Tue, 17 Jan 2023 20:56:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C0846B0074; Tue, 17 Jan 2023 20:56:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 884846B0071 for ; Tue, 17 Jan 2023 20:56:20 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 551241204FE for ; Wed, 18 Jan 2023 01:56:20 +0000 (UTC) X-FDA: 80366254920.22.22BCD1A Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf20.hostedemail.com (Postfix) with ESMTP id 62FBB1C0002 for ; Wed, 18 Jan 2023 01:56:18 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=uluUZb7g; spf=pass (imf20.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674006978; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CyWTxF4FfJMeDbUGZTVRzt6Lmnq30K9ei9PlhTnyc/s=; b=qHTkKu5DLt0Iu92HP0QGOU7BvCEpgW3GCnF1LOcdmqa0iMnVbmax7UCSOQfNLDMHaReubI Kaqmn1Wyrp0k4uX41fCs70EApiWg801gKf6cKVAzLTsMnTLEigs24ee7As+t/h8WTFF4PM I+AO6SFkDuUavJYw2QGkgXQWfmx0GHE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=uluUZb7g; spf=pass (imf20.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674006978; a=rsa-sha256; cv=none; b=MuJUEmFUl6Ay02h2mMaPWFoRd3dwfJQ8TtrRLB6CssnjAGpuNiOJ5b85NG4dnXn9volzgs OS35HKw5trZ6LF0pHtpZJ0zt9RmP8psx3yUEOMpJcRDhP6JMDjWGIPsKYWaMuwpPF8Ci/j gkyuNUFPvYXUDEtU05u/B/X4TBtv6rc= Date: Wed, 18 Jan 2023 10:56:07 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1674006975; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=CyWTxF4FfJMeDbUGZTVRzt6Lmnq30K9ei9PlhTnyc/s=; b=uluUZb7gb/031l90RszkUgv+R23MlNN1gM9xJ6uuErvXIsK5hBi8tJ8c/6Jd91pZehWp4l C2PI8CodSCp5WYWcHLFwy828AfcxpeiDMFJ7rHTR+OLNC0YGQmh1JkHJO3vgYIkBw0uPu7 b0r6MWymx1k0Xf18uoBYfFgH+5bhJA4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Naoya Horiguchi To: Sidhartha Kumar Cc: Mike Kravetz , Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, songmuchun@bytedance.com, jhubbard@nvidia.com Subject: Re: [PATCH mm-unstable v2 8/8] mm/hugetlb: convert demote_free_huge_page to folios Message-ID: <20230118015607.GA1620837@u2004> References: <20230110212821.984047-1-sidhartha.kumar@oracle.com> <20230110212821.984047-9-sidhartha.kumar@oracle.com> <2f9ef115-a508-090b-d804-23235a447063@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <2f9ef115-a508-090b-d804-23235a447063@oracle.com> X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 62FBB1C0002 X-Stat-Signature: i4xc64x7uf711pedka8azi15sts36f7a X-HE-Tag: 1674006978-658378 X-HE-Meta: U2FsdGVkX1+0U5v52HFuJ9PUKg4EawG73pKhvZnNNkzg70Mx/kZ9bFi/xkIxH3cOSGPkCt7UJ7fNPKSx8CpJqMeVdfKwdNVnNjGZY/Lk1HYS7/KHxlywgSfV0B7WsJptyV3chTkBUzczLiHi5I6PVktbTTbybbjd0wlNQjIZ6y0MG7cK5obiM9WM8+TUhW6ajDJ46vg5nJpd5sb/3URGsK9q5AdYx2xxPgJ2XNYh1gjDczKB+mB980oT/aWCBnD9Jc/O70/cZUjB/j3XX4HdQPNMxvqxc4YGi51YJmBMaz21tqFuDvWPjJvlOiUYHDhYHLeVBTo9KH0ZTbViaTN7po3GY/veI4NVOt6E6VF4zbp8ew3yE1qSmdetskopc1KDTrA7VPABjx87zYO/mD6kSj9gwesQwZWT8DogeS+00SbxNK6rd6yaVxShILTDh4692fT/DM6JJwQSgalH0oNiOZ94OyUBUGm997iu7n4eykXoZw8Sl+1wR156AYJxIBQtN1WfVAfXiTFrMqAjVTQugQnO8ylZTM6VGmQf5ey5pxMHeOwRs/0X8KwvD5KdgY7EnHhQkGiDlSL+FAANNanWP1KcccLq2HXY9Wa+wnwjIIBJ76QMOw71HCX/Dmk6445sErNDjhZ1zXBknJesFBvDzQK6zpvotQhScMu9y1V2YESYkRpozdZEpNxGPFgyqommyOLG+WXFo8ndcPxEPbPBPbXQmLHzccF9pINk4FksofPzCZ/pDR4CIITrSjOp0/BkwSyztMVHiELStDPntrtvPPmneboMV4c2MRkOh04ud1p7h3YmG3n0tMsGVz2sgDPaZRurPewzuB+yAUURlroW8Uki4/cvqB4X+AMi+FN0Auc= 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 Fri, Jan 13, 2023 at 09:16:23AM -0600, Sidhartha Kumar wrote: > On 1/10/23 6:00 PM, Mike Kravetz wrote: > > On 01/10/23 21:40, Matthew Wilcox wrote: > > > On Tue, Jan 10, 2023 at 03:28:21PM -0600, Sidhartha Kumar wrote: > > > > @@ -3505,6 +3505,7 @@ static int demote_pool_huge_page(struct hstate *h, nodemask_t *nodes_allowed) > > > > { > > > > int nr_nodes, node; > > > > struct page *page; > > > > + struct folio *folio; > > > > lockdep_assert_held(&hugetlb_lock); > > > > @@ -3518,8 +3519,8 @@ static int demote_pool_huge_page(struct hstate *h, nodemask_t *nodes_allowed) > > > > list_for_each_entry(page, &h->hugepage_freelists[node], lru) { > > > > if (PageHWPoison(page)) > > > > continue; > > > > - > > > > - return demote_free_huge_page(h, page); > > > > + folio = page_folio(page); > > > > + return demote_free_hugetlb_folio(h, folio); > > > > } > > > > } > > > > > > Can't this be > > > list_for_each_entry(folio, &h->hugepage_freelists[node], lru) > > > > > > which avoids the call to page_folio() here. > > > > > > I think the call to PageHWPoison is actually wrong here. That would > > > only check the hwpoison bit on the first page, whereas we want to know > > > about the hwpoison bit on any page (don't we?) So this should be > > > folio_test_has_hwpoisoned()? > > > > > > Or is that a THP-thing that is different for hugetlb pages? > > > > I believe it is different for hugetlb pages. See hugetlb_set_page_hwpoison() > > where it sets PageHWPoison on head page as well as allocating a raw_hwp_page > > I agree, this line in hugetlb_set_page_hwpoison (which is now > folio_set_hugetlb_hwpoison) sets the HWPoison flag on the head page > > int ret = folio_test_set_hwpoison(folio) ? -EHWPOISON : 0; > > so the correct code in demote_pool_huge_page() would be: > > list_for_each_entry(folio, &h->hugepage_freelists[node], lru) { > if (folio_test_hwpoison(folio)) > continue; > return demote_free_hugetlb_folio(h, folio); > } > > > > to track the actual page with poison. Note that we can not directly flag > > hugetlb 'subpages' because we may not have the struct pages due to vmemmap > > optimization. Adding Naoya just to be sure. Yes, the above code and the reason totally make sense to me. Thanks for the patch and the update. - Naoya Horiguchif