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=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 B9755C433B4 for ; Mon, 17 May 2021 11:34:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5EC6361073 for ; Mon, 17 May 2021 11:34:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5EC6361073 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E1DC46B0036; Mon, 17 May 2021 07:34:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DCDF26B006E; Mon, 17 May 2021 07:34:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C20986B0070; Mon, 17 May 2021 07:34:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id 8EC9A6B0036 for ; Mon, 17 May 2021 07:34:10 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2DF0D8419 for ; Mon, 17 May 2021 11:34:10 +0000 (UTC) X-FDA: 78150514260.07.3EC3E86 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by imf22.hostedemail.com (Postfix) with ESMTP id E4489C0007C9 for ; Mon, 17 May 2021 11:34:08 +0000 (UTC) Received: by mail-pg1-f177.google.com with SMTP id t193so4453453pgb.4 for ; Mon, 17 May 2021 04:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=SemXkCbow4yBXflzyDjNxahJ+Elgl4A0uyCJv5Cq9YU=; b=DGAyxqLgz3OO1MWLx8qiw1QtWW+DLDx7vUUkjOIhutGsiOt+YlE5BHfM5e21woX6cG h4BaS5ayqZ7xjC7FGxpccTNVf2+Gplw1SUXZGd1h3g+E5zezVy68TW05Hf44BDzfoYFv 3jKBAGy69n78QmAxPzyHMt027++pHWHbuoIxhwI7IFSfMRoBUx7whlOpMb63xsq+bqDV HkpE2lrrYiwnXeAqmNnQtSqaOa3XJLFcraZ6lJ8/p+zZ8bOsHPNEY8/ZTkjh4s1Wg75K gEVP49iODFG12j5B5KoBARKByHZLg5mwxrTci1dS1Ppq4AhZ2RgAl+i8eehY/OAHLO98 liHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SemXkCbow4yBXflzyDjNxahJ+Elgl4A0uyCJv5Cq9YU=; b=d/ABWvzRvPacgNPA0qni2zr7kHhI2SCLIL3mcXEv5TCDTBG/iWZvNGai9XXwpLDWLa vl4Ewhm33GpJANtvZnfZswyaP/jVi+96wqIPgxfhuIgnTovw6UkOoI5fHYno173Tbt0c 9+cOzxLylku7j+nUzR3oF0G2wymBqvT3OlP1Pql9pfuuGmUv8CTeRTcOq+JTm2B7gwMQ hyspHjDj8WPWYjNsXNy3aHxme2s2yLeYFGpejvLGRZ5Jn60SnQPEhz2S3nvPSn6MxeqF t0joUdI0CUu4bmsil1XGNus4wt4rH5qxSUSzCp3qVro7qedz042wh3wms03ITbOB2yhH 4NBg== X-Gm-Message-State: AOAM532l/kdr128/KVcFjW5lmC2uQk3tz2qtnhfU/TykhirdCvQH0KSQ SIMIbpGoe9+MbHqtXBBAGg== X-Google-Smtp-Source: ABdhPJxGpZMBXtHpJPSmLqncN7Qur27kVlCHiJBfWTl77Rr67A+c0ruFAftsy1htis9tdyGwjvM9JA== X-Received: by 2002:a63:6c9:: with SMTP id 192mr4922117pgg.39.1621251248820; Mon, 17 May 2021 04:34:08 -0700 (PDT) Received: from u2004 (h175-177-040-153.catv02.itscom.jp. [175.177.40.153]) by smtp.gmail.com with ESMTPSA id i7sm1351944pgv.93.2021.05.17.04.34.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 04:34:08 -0700 (PDT) Date: Mon, 17 May 2021 20:34:05 +0900 From: Naoya Horiguchi To: Oscar Salvador Cc: Muchun Song , linux-mm@kvack.org, Andrew Morton , Mike Kravetz , Michal Hocko , Tony Luck , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/2] mm,hwpoison: fix race with compound page allocation Message-ID: <20210517113405.GA2512538@u2004> References: <20210517045401.2506032-1-nao.horiguchi@gmail.com> <20210517045401.2506032-2-nao.horiguchi@gmail.com> <20210517101239.GA21612@linux> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210517101239.GA21612@linux> X-Rspamd-Queue-Id: E4489C0007C9 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=DGAyxqLg; spf=pass (imf22.hostedemail.com: domain of naohoriguchi@gmail.com designates 209.85.215.177 as permitted sender) smtp.mailfrom=naohoriguchi@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Stat-Signature: oai88qhmitg84mpgkwa9riza7xkiddjo X-HE-Tag: 1621251248-439033 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, May 17, 2021 at 12:12:50PM +0200, Oscar Salvador wrote: > On Mon, May 17, 2021 at 01:54:00PM +0900, Naoya Horiguchi wrote: > > From: Naoya Horiguchi > > > > When hugetlb page fault (under overcommitting situation) and > > memory_failure() race, VM_BUG_ON_PAGE() is triggered by the following race: > > > > CPU0: CPU1: > > > > gather_surplus_pages() > > page = alloc_surplus_huge_page() > > memory_failure_hugetlb() > > get_hwpoison_page(page) > > __get_hwpoison_page(page) > > get_page_unless_zero(page) > > zero = put_page_testzero(page) > > VM_BUG_ON_PAGE(!zero, page) > > enqueue_huge_page(h, page) > > put_page(page) > > > > __get_hwpoison_page() only checks page refcount before taking additional > ^^ the? ^^ an > > one for memory error handling, which is wrong because there's a time > > window where compound pages have non-zero refcount during initialization. > > > > So makes __get_hwpoison_page() check page status a bit more for a few > ^^ make > > types of compound pages. PageSlab() check is added because otherwise > > "non anonymous thp" path is wrongly chosen. > > This is no longer true with this patch, is it? What happened here? Sorry, we need remove this. I dropped the changes for PageSlab because I'm still not sure about what to do (I'd like to do it in a separate work). > > > static int __get_hwpoison_page(struct page *page) > > { > > struct page *head = compound_head(page); > > + int ret = 0; > > + > > +#ifdef CONFIG_HUGETLB_PAGE > > + spin_lock(&hugetlb_lock); > > + if (PageHuge(head) && (HPageFreed(head) || HPageMigratable(head))) > > + ret = get_page_unless_zero(head); > > + spin_unlock(&hugetlb_lock); > > + if (ret > 0) > > + return ret; > > +#endif > > I am kind of fine with this, but I wonder whether it makes sense to hide this > details into helper (with an empty stub for non-hugetlb pages)? OK, I will do this. > > > if (!PageHuge(head) && PageTransHuge(head)) { > This !PageHuge could go? I'll update this, too. Thanks, Naoya Horiguchi