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 B7809C77B7A for ; Fri, 19 May 2023 20:54:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C06FF900004; Fri, 19 May 2023 16:54:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BB74E900003; Fri, 19 May 2023 16:54:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A802C900004; Fri, 19 May 2023 16:54:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 991AE900003 for ; Fri, 19 May 2023 16:54:32 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7108A120B90 for ; Fri, 19 May 2023 20:54:32 +0000 (UTC) X-FDA: 80808207984.14.01DE36F Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) by imf14.hostedemail.com (Postfix) with ESMTP id AA04B10000D for ; Fri, 19 May 2023 20:54:30 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=D18JUVsL; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf14.hostedemail.com: domain of jiaqiyan@google.com designates 209.85.128.172 as permitted sender) smtp.mailfrom=jiaqiyan@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684529670; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=B95I2ErHfSKpIP3GGiqUWw60UUrTwERJDKlWWGCQqAQ=; b=aq2bCK2o07BPntpgUnw+pLsGId1KTNMOc6EsYGdzewilu0fG1AXEqDUyRB67QlT1Cv9/Vh SpTL/kDON0W60LmCHXzETM/fcVSejp86VCazLOE9FzFb4Yk0eyx9aW18xYiDCwCMjZ8PFi jC+NqhhXLxurVl7x+n8pH8Mb/ASXOR0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=D18JUVsL; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf14.hostedemail.com: domain of jiaqiyan@google.com designates 209.85.128.172 as permitted sender) smtp.mailfrom=jiaqiyan@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684529670; a=rsa-sha256; cv=none; b=ay1wK8cGF2cOGFVbmSBr8xmry8dsE4ht9IBOVNGbYDkIi3SN/1ea19zzVI4IJmz3U2PKoZ 0V7PuN9xYQ8n8rd1Q8ewabRxtp/DZKm8ufTgcY8YQgTA11q7r8l+wB5xRJR51P6vgGgiQw gS/hRfLS14jYXTzj5IfSQ0MpzOgfwUA= Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-561b65b34c4so51404187b3.1 for ; Fri, 19 May 2023 13:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684529670; x=1687121670; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=B95I2ErHfSKpIP3GGiqUWw60UUrTwERJDKlWWGCQqAQ=; b=D18JUVsLkLZpjvIl5h5Dwd1u8deHaloBFH+VD56K9Pdzc3bUoQb6zAaly1nHAbG4tg hSUhiBTQAzZMvTnFds5VA/Luy9aSR7sOTjKihgkwllwh6hj1+yqzRRBL/Qa5sVJ+5AGV FOtgOdXbjAdTsFhW7DwRRvDoaAAiSlghKBrbyrwW66or+00+Yiiy3mau838YOBmQyFv3 4KWfcXdDmWw4JDDXlThdopr/dMvXQgfNx2JviUt4N3LQXdsQ2q5sFkACnAL4eNS122+G VX8qB8CxUjETI+qFntxQ1VOItlyzKQvXkXphMqDNGBAK9CEW9l98Qeo+/DgbgAgDe0Rq cR4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684529670; x=1687121670; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B95I2ErHfSKpIP3GGiqUWw60UUrTwERJDKlWWGCQqAQ=; b=Tc+tvA0VIs2gB36NOR4wQ7N6R0UtTQHHbjUOvVsBEKBi8C0/Rqioyvvs5f7wi/Yh3d TnU6c/RF0tazDoCoTMWxfU3RESShSKIAFJvqJG+V6z+xsOjGr03JRGwJ3K9562VnyCbf XBbuJ/UhtJvsN4hPDe6mrjTCrV4DDeeXENc752TdtVLTCVdUXE6oQK2WQqQk/Qmn+6GW VSX/bsBv2Uz/GsViS0IlzK9ICI0eM3/yqXTsyh7nED4WwClpM8/VC+Hy9ISNJGWQXm3H L83dqV+T2SnIXIHf/jaK+xW99sHqO2xlwI3ESxYrCka+b1hqizQLcwwfUcdf2JN6D8LI 92Ng== X-Gm-Message-State: AC+VfDxh9hDtxaTAhZE7P0urHMuhPe2p00NIku5Y/CSIeIiy2CTHpZg+ jI8/PEbjtcqjClqNVOj5udR/ZAAhJG4ZjWFpW7W2DA== X-Google-Smtp-Source: ACHHUZ7PilSNBvSKDgQ0Ty7EsCa7E2fB2HBgS0jvDO3j1+0fsunx8Hx6LGEPhE48lpQ8s/MJQFmCDRbkT8ISYeuVkFs= X-Received: by 2002:a81:a554:0:b0:562:1060:f2c9 with SMTP id v20-20020a81a554000000b005621060f2c9mr3296846ywg.13.1684529669598; Fri, 19 May 2023 13:54:29 -0700 (PDT) MIME-Version: 1.0 References: <20230517160948.811355-1-jiaqiyan@google.com> <20230517160948.811355-2-jiaqiyan@google.com> <20230517235314.GB10757@monkey> In-Reply-To: <20230517235314.GB10757@monkey> From: Jiaqi Yan Date: Fri, 19 May 2023 13:54:18 -0700 Message-ID: Subject: Re: [PATCH v1 1/3] mm/hwpoison: find subpage in hugetlb HWPOISON list To: Mike Kravetz Cc: songmuchun@bytedance.com, naoya.horiguchi@nec.com, shy828301@gmail.com, linmiaohe@huawei.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, duenwen@google.com, axelrasmussen@google.com, jthoughton@google.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: AA04B10000D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: whzbq3k8xnc3m6eem5yi6z83xu8engsr X-HE-Tag: 1684529670-655251 X-HE-Meta: U2FsdGVkX1/Vj/e8QP7jv4KlUap23qwY1HFpcYaIWMgzB3lQwq9w+qdockZDToYiCVya9Wc05ylsDIvs24Js4fIN1muhwb0aK/xT0I6FIoMzGQQ1SG27xUxMXNPiAaExxE/vdaraZrebcHWZ8zV5SLFGFyrJu5oUxnCQhAJxUnYoXhmUPQFapXZKMjCRx0EebeUSlVqaSPEHxewIzLKTF+GiWT+/Mh27euxh/6RgOuae7qudATgbkYY/xyJRAZ48+hpmzvoDl0QzM7DB4FxKJhwbvX0cWs16sA0HBeGOOX5Dnzlu5t08rNVrAQzVzvQtmlxr8bwaGtUfP25PeJNbhUc37SkeT93PSDOjn16DCo3RV/3RkmuynhX73X31uITlfjzy+RPiG656Oa+LmRX8Jdy8rAKbmXmt9UgXMyw3QEWhnvR+wXqELx5WVVU0DCt3dLt5cnfbgCT4TLW04Aife0Ae0wLjx9LXBELg3vbfPFGOIa2FUr0lKhhHQyG7ZChiLF4/m+x6orvMeQ/LD7kPGbZ9FpTkEnKlZzVSYmLQZH8awVeYf30CJPewvD/itax5GIkuzcVye+wASe3bwslDdFZrRoHaQ35Fqjkh3h5mXcaMmvJfC7tf3polaZIwuuGjM8ehbDWfyUCTEgA/3D7VlRq12YLXzyKDYtJAcvIMJSQT2ucM6/42ggXjkFTFwZEc93Uuyj099xGp38jfkwfYmXLXJ673d3kfk9WtYD8ea9FB0g2ortQP5od31yxNCp1453wKoah98Wytrk7SVkz7efCUCzYBFCzRqM9W8T7YBmlLvSx6gKv4oytDLdoOFxKBLxig8Gl5WL3qxcCZdZVmyWe92Pkf5g6ICVfqUGyJ0GgOIrb6+HOb5T3LQUesGTPQqtcUz4yMMWiq5dCnxmWO8at+lA5Tg7qZwSxnRJLai361Trc9XP8e+Bibaffeh01o3FQE8HDFg1UrhuvTZ4D WEeAflWH mLd7g1NaZcZzmnn4eGhgsAio/mqdfVwN6xBjm61DrDZP0vqLt5EHMppq3eALQk6Z73DvVcb1+LzgLI5rXdbr3s1jqVMPASJrIKeTttdAbxig+1IKVberCOdtcZ61gO+Uz9qhnWmTOnpWer1d0KYODWpt0lqWx3SsSK90cuklevYuDhOfA085Tvr4iAJ3VD8JxHzbxKt2Yqi3oIxdKu/T60jF0os0t4rAbWhgb+kx159puEaq1I9pj51yZItbUyf8ycz9GXHEKJBTuOddjJCNXqfX0cQ== 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 Wed, May 17, 2023 at 4:53=E2=80=AFPM Mike Kravetz wrote: > > On 05/17/23 16:09, Jiaqi Yan wrote: > > Adds the functionality to search a subpage's corresponding raw_hwp_page > > in hugetlb page's HWPOISON list. This functionality can also tell if a > > subpage is a raw HWPOISON page. > > > > Exports this functionality to be immediately used in the read operation > > for hugetlbfs. > > > > Signed-off-by: Jiaqi Yan > > --- > > include/linux/mm.h | 23 +++++++++++++++++++++++ > > mm/memory-failure.c | 26 ++++++++++++++++---------- > > 2 files changed, 39 insertions(+), 10 deletions(-) > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index 27ce77080c79..f191a4119719 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > Any reason why you decided to add the following to linux/mm.h instead of > linux/hugetlb.h? Since it is hugetlb specific I would have thought > hugetlb.h was more appropriate. > > > @@ -3683,6 +3683,29 @@ enum mf_action_page_type { > > */ > > extern const struct attribute_group memory_failure_attr_group; > > > > +#ifdef CONFIG_HUGETLB_PAGE > > +/* > > + * Struct raw_hwp_page represents information about "raw error page", > > + * constructing singly linked list from ->_hugetlb_hwpoison field of f= olio. > > + */ > > +struct raw_hwp_page { > > + struct llist_node node; > > + struct page *page; > > +}; > > + > > +static inline struct llist_head *raw_hwp_list_head(struct folio *folio= ) > > +{ > > + return (struct llist_head *)&folio->_hugetlb_hwpoison; > > +} > > + > > +/* > > + * Given @subpage, a raw page in a hugepage, find its location in @fol= io's > > + * _hugetlb_hwpoison list. Return NULL if @subpage is not in the list. > > + */ > > +struct raw_hwp_page *find_raw_hwp_page(struct folio *folio, > > + struct page *subpage); > > +#endif > > + > > #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLBFS) > > extern void clear_huge_page(struct page *page, > > unsigned long addr_hint, > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > > index 5b663eca1f29..c49e6c2d1f07 100644 > > --- a/mm/memory-failure.c > > +++ b/mm/memory-failure.c > > @@ -1818,18 +1818,24 @@ EXPORT_SYMBOL_GPL(mf_dax_kill_procs); > > #endif /* CONFIG_FS_DAX */ > > > > #ifdef CONFIG_HUGETLB_PAGE > > -/* > > - * Struct raw_hwp_page represents information about "raw error page", > > - * constructing singly linked list from ->_hugetlb_hwpoison field of f= olio. > > - */ > > -struct raw_hwp_page { > > - struct llist_node node; > > - struct page *page; > > -}; > > > > -static inline struct llist_head *raw_hwp_list_head(struct folio *folio= ) > > +struct raw_hwp_page *find_raw_hwp_page(struct folio *folio, > > + struct page *subpage) > > { > > - return (struct llist_head *)&folio->_hugetlb_hwpoison; > > + struct llist_node *t, *tnode; > > + struct llist_head *raw_hwp_head =3D raw_hwp_list_head(folio); > > + struct raw_hwp_page *hwp_page =3D NULL; > > + struct raw_hwp_page *p; > > + > > + llist_for_each_safe(tnode, t, raw_hwp_head->first) { > > IIUC, in rare error cases a hugetlb page can be poisoned WITHOUT a > raw_hwp_list. This is indicated by the hugetlb page specific flag > RawHwpUnreliable or folio_test_hugetlb_raw_hwp_unreliable(). > > Looks like this routine does not consider that case. Seems like it shoul= d > always return the passed subpage if folio_test_hugetlb_raw_hwp_unreliable= () > is true? Thanks for catching this. I wonder should this routine consider RawHwpUnreliable or should the caller do. find_raw_hwp_page now returns raw_hwp_page* in the llist entry to caller (valid one at the moment), but once RawHwpUnreliable is set, all the raw_hwp_page in the llist will be kfree(), and the returned value becomes dangling pointer to caller (if the caller holds that caller long enough). Maybe returning a bool would be safer to the caller? If the routine returns bool, then checking RawHwpUnreliable can definitely be within the routine. Another option is, this routine simply doesn one thing: find a raw_hwp_page in raw_hwp_list for a subpage. But the caller needs to 1) test RawHwpUnreliable before calls into the routine, and 2) test RawHwpUnreliable before access returned raw_hwp_page*. I think 2nd option will be error-prone and the 1st option is a better one. Maybe I am over-thinking. What do you think? > -- > Mike Kravetz > > > + p =3D container_of(tnode, struct raw_hwp_page, node); > > + if (subpage =3D=3D p->page) { > > + hwp_page =3D p; > > + break; > > + } > > + } > > + > > + return hwp_page; > > } > > > > static unsigned long __folio_free_raw_hwp(struct folio *folio, bool mo= ve_flag) > > -- > > 2.40.1.606.ga4b1b128d6-goog > >