From patchwork Fri Jul 31 12:20:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694827 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A122913 for ; Fri, 31 Jul 2020 12:21:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 05DC92087C for ; Fri, 31 Jul 2020 12:21:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MLRvIBPy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 05DC92087C 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 5DD508D0024; Fri, 31 Jul 2020 08:21:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5641A8D000B; Fri, 31 Jul 2020 08:21:23 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3BA498D0024; Fri, 31 Jul 2020 08:21:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id 0E9FF8D000B for ; Fri, 31 Jul 2020 08:21:23 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C0898824805A for ; Fri, 31 Jul 2020 12:21:22 +0000 (UTC) X-FDA: 77098281204.26.death45_5406dbe26f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 656C21804B65C for ; Fri, 31 Jul 2020 12:21:22 +0000 (UTC) X-Spam-Summary: 1,0,0,61f9c3cfe9335b0f,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:355:379:541:800:960:968:973:981:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2899:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3871:4321:5007:6261:6653:6742:7576:8957:9413:10004:11026:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12740:12895:13069:13311:13357:14096:14181:14384:14394:14721:21060:21080:21222:21444:21627:21666:22119:30012:30046:30054:30064:30070:30079,0,RBL:209.85.214.194:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yr11nag86ofis5eix33rfojyry6opdwtax7s65ikqi37pg5kiabxmcwiyh9ri.4pati96mrt7cmom43bxrncxagga88hk3oqa4mqyitbqbytbc67ktd6r4t18gq95.1-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: death45_5406dbe26f83 X-Filterd-Recvd-Size: 4340 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:21:22 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id b9so17221747plx.6 for ; Fri, 31 Jul 2020 05:21:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pS0WhU6WE8IYcQCnD1IwwP5QRHOYUjKqdATKfccEtHE=; b=MLRvIBPy5vqHYOrJlKbuO+hv+7xtTvwRappzGjqJukqCM0eBVWt6DsxRLnwWNYS5GL 5l3SSvwdz0LgMaCUAnjg0HOQl2EbBMFmBqPs9VD4JhVaTcCpyUu6SWbyfMW8aBKwIjYe v+b0EZVomIUg7AsgLIBernDe2VaddoZoE1KSwBautGPyYU6Eio8RVl8oRLk6Wtm3F5Al pv8zQRFG78hNGhNre4/0LDEP1L8XUlHvPh9xaCOcQ7NQ2T1oOFvf00XoE5bljF50yW86 vYj5A4tYt4RYzkhRPFdDj7mzY5crKu9AqqqFmTeK9hUhyxB6SOubKzz7kNsvgRznFFBQ HxzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pS0WhU6WE8IYcQCnD1IwwP5QRHOYUjKqdATKfccEtHE=; b=EmGJuYwObqqL7a/HFImlQetM5xKU7nZLFzHg25GYQdqnm9UiGiowVTtSVB3mCu7kGt byqo2KFR+MmF12Wu4lRHfwOjguBasDCCona/8Frs//0gToXjF2EpxLHuHqTvVPVDKGoQ n6RkNCIpJc+RGvW291H5c7HRyoph7Jsy+hDIMhY6zz5xaA8V3gfMEgZGvaY9H50rf00O XVqFVmiG8/VFMXedIMAoHIt8msf39oJG3p7y2PmK8oyrJqiDAwvYp7fA41waBAQxySk+ BJUaoO9zZ1EbKqdPwRu+l3oC7CThtbcP7eA1Wykf5UZnQvxxFWSQWK1x6THHxTjpGNJS BXbw== X-Gm-Message-State: AOAM5338Bx6Jrg8gSv6U+gzRzUF4EotelpBJRSn8wZJsjYmevtuX1GNS Dw7icIyir2ek30Q1eJ5+Ad0qEnJdvA== X-Google-Smtp-Source: ABdhPJyexxScAh6tJturIlM6+21A1G4mPGy9rhb+3ZLAMULac3Oa3rj79jfqnQ4zsDb+GEJ4UvcFaw== X-Received: by 2002:a17:90a:9f84:: with SMTP id o4mr3700149pjp.200.1596198081054; Fri, 31 Jul 2020 05:21:21 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:20 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 01/16] mm,hwpoison: cleanup unused PageHuge() check Date: Fri, 31 Jul 2020 12:20:57 +0000 Message-Id: <20200731122112.11263-2-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 656C21804B65C X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: From: Naoya Horiguchi Drop the PageHuge check, which is dead code since memory_failure() forks into memory_failure_hugetlb() for hugetlb pages. memory_failure() and memory_failure_hugetlb() shares some functions like hwpoison_user_mappings() and identify_page_state(), so they should properly handle 4kB page, thp, and hugetlb. Signed-off-by: Naoya Horiguchi Signed-off-by: Oscar Salvador Reviewed-by: Mike Kravetz --- mm/memory-failure.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c index fe53768e0793..3d2d61f1c6e9 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c @@ -1382,10 +1382,7 @@ int memory_failure(unsigned long pfn, int flags) * page_remove_rmap() in try_to_unmap_one(). So to determine page status * correctly, we save a copy of the page flags at this time. */ - if (PageHuge(p)) - page_flags = hpage->flags; - else - page_flags = p->flags; + page_flags = p->flags; /* * unpoison always clear PG_hwpoison inside page lock From patchwork Fri Jul 31 12:20:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694829 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8ED2F913 for ; Fri, 31 Jul 2020 12:21:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 525DB21D95 for ; Fri, 31 Jul 2020 12:21:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WH9dCgiO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 525DB21D95 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 2D0758D0027; Fri, 31 Jul 2020 08:21:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 208FE8D0025; Fri, 31 Jul 2020 08:21:26 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0826B8D0027; Fri, 31 Jul 2020 08:21:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0081.hostedemail.com [216.40.44.81]) by kanga.kvack.org (Postfix) with ESMTP id D7E778D0025 for ; Fri, 31 Jul 2020 08:21:25 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A4DE13626 for ; Fri, 31 Jul 2020 12:21:25 +0000 (UTC) X-FDA: 77098281330.07.stamp11_250707326f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 746BE1803F9AA for ; Fri, 31 Jul 2020 12:21:25 +0000 (UTC) X-Spam-Summary: 1,0,0,469be48e7ebaa894,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1431:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2895:2899:3138:3139:3140:3141:3142:3352:3865:3866:3867:3870:3871:4321:5007:6119:6261:6653:6742:7576:7903:9413:10004:11026:11473:11658:11914:12043:12297:12438:12517:12519:12555:12679:12740:12895:13069:13311:13357:14096:14181:14384:14394:14721:21060:21080:21444:21451:21627:21666:21795:22119:30051:30054:30064:30070,0,RBL:209.85.216.68:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04ygd4iywdamcm6qe8j8sizosethbopb3r63bkhr1u39sa9ichxy7dxjrfnxx6z.8z87abptc5rjm1a8tnbec11d1shp8icjn7qyc4kh3rhfpmi7b3dkq6qmfb8ctyt.w-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: stamp11_250707326f83 X-Filterd-Recvd-Size: 4512 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:21:24 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id a9so7212619pjd.3 for ; Fri, 31 Jul 2020 05:21:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qrNOopevZrXOPbrUYdqc/luUXjhR4msmU2SD/x7wn8s=; b=WH9dCgiO5HBSnguxla+ODFX+58yP55FDN85r1k7Xc0tjEBA7/8Y7Ch2O85TIWJU5Zj od7uQJV/H6YraW6Rm48YMoGsmqjiwFaS3jQ8BpARANZ5MKWhWodJvPLk0Qy4h8ufVJY4 ZVjQFAuRWkEPboJX16lJwqsNOknYnqAB8kjdyL3ugGNcH+pnASg/Td4s0zXFQtsSMSqF BNYJp2L+kSBJn3OXXfNamLP2Podb6Ow0fekn3qQhte4yzJzwU1Y6jKAB6py+fh/THd8y S9Pm3Dx8YfAHd87lMiB2UatTv52EzEmzwgoHEWQlEzZVS+O5AyGwnHESLsUoymdc5U+4 wmxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qrNOopevZrXOPbrUYdqc/luUXjhR4msmU2SD/x7wn8s=; b=HlohPEd8LpOJw6nEbimbqh3PCuGjCG5ZwF+/QgZIJq0/XlSPZUdZsqnHwJZOq6LzTe y5lS1mt/AIKi/Uc9hzAoKq5GkbAKgpITdnUwQ+I6r05DNj9UjrHxsH74CUr2gxu9LIbj z4ZXE6ZDPXDxc6QxlwFvrHAtnGHOGVVXvtUzAVgsARR3rh9I5p1YT8e0tiRK92DuFGe8 BsDisLEO/cIVh2/FTpPPyCJmHns1DYXEeqakKMdK334OCWR673C16cpBASx/tnPSGDCE 3c7MbAs8SUEg8aJ43J42t1U4W//YvpmcXor7TFz2XCDJUmSpSVkoVLB7RTEap0VHFdjm XjtQ== X-Gm-Message-State: AOAM531ZHWjhxrivewcp3U3qhfUl95busAG12dcB2kSLg10zgTzDs8Nw 0mmEhiTV+ciA9ElNkYlpHx9fUAj8KQ== X-Google-Smtp-Source: ABdhPJx8PolYkpiawKpv9KQGOzCfR/2h6vcz2gh903lD7zOol4BIdtxScC5xzPjV0Nvs/PYmFUz4ow== X-Received: by 2002:a63:3c41:: with SMTP id i1mr3580839pgn.349.1596198084144; Fri, 31 Jul 2020 05:21:24 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:23 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 02/16] mm, hwpoison: remove recalculating hpage Date: Fri, 31 Jul 2020 12:20:58 +0000 Message-Id: <20200731122112.11263-3-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 746BE1803F9AA X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: From: Naoya Horiguchi hpage is never used after try_to_split_thp_page() in memory_failure(), so we don't have to update hpage. So let's not recalculate/use hpage. Suggested-by: "Aneesh Kumar K.V" Signed-off-by: Naoya Horiguchi Signed-off-by: Oscar Salvador Reviewed-by: Mike Kravetz --- mm/memory-failure.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c index 3d2d61f1c6e9..f8d200417e0f 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c @@ -1342,7 +1342,6 @@ int memory_failure(unsigned long pfn, int flags) } unlock_page(p); VM_BUG_ON_PAGE(!page_count(p), p); - hpage = compound_head(p); } /* @@ -1414,11 +1413,8 @@ int memory_failure(unsigned long pfn, int flags) /* * Now take care of user space mappings. * Abort on fail: __delete_from_page_cache() assumes unmapped page. - * - * When the raw error page is thp tail page, hpage points to the raw - * page after thp split. */ - if (!hwpoison_user_mappings(p, pfn, flags, &hpage)) { + if (!hwpoison_user_mappings(p, pfn, flags, &p)) { action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED); res = -EBUSY; goto out; From patchwork Fri Jul 31 12:20:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694831 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 181B8913 for ; Fri, 31 Jul 2020 12:21:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D964C22BEA for ; Fri, 31 Jul 2020 12:21:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eFV6haNp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D964C22BEA 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 6C5A48D0029; Fri, 31 Jul 2020 08:21:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 64E5A8D0028; Fri, 31 Jul 2020 08:21:29 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F1308D0029; Fri, 31 Jul 2020 08:21:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0140.hostedemail.com [216.40.44.140]) by kanga.kvack.org (Postfix) with ESMTP id 2DD698D0028 for ; Fri, 31 Jul 2020 08:21:29 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E363C180AD802 for ; Fri, 31 Jul 2020 12:21:28 +0000 (UTC) X-FDA: 77098281456.29.cakes70_0d127f326f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id B771018086E24 for ; Fri, 31 Jul 2020 12:21:28 +0000 (UTC) X-Spam-Summary: 30,2,0,76dd262a74f594c5,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:2898:2899:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:3874:4321:4641:5007:6119:6261:6653:6742:7576:7903:8603:8660:9413:9592:10010:11026:11473:11658:11914:12043:12297:12438:12517:12519:12555:12679:12740:12895:13148:13161:13180:13229:13230:13255:14181:14394:14721:21060:21080:21212:21444:21627:21666:21740:21939:21987:21990:22119:30003:30054:30064:30070:30091,0,RBL:209.85.216.68:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yg4ir1e1ueg7mrho9jyqhkcxa9nopmnop3bs8kurqe1tsa89q3kmcmtx95uec.x1a5ffpk7runksubhjmfx7cap8sybyuubpepwk9ajtnmuf1uermztt76d6s1tnf.r-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:1:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: cakes70_0d127f326f83 X-Filterd-Recvd-Size: 5394 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:21:28 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id mt12so7211229pjb.4 for ; Fri, 31 Jul 2020 05:21:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FBTrDXNWXY7ZPAJHB1q2pmYieIRphOe/mMSwCtpIV18=; b=eFV6haNpyacgxwgVMRx4A+6Q956GlMW1U7F59KBLih3bqhXIVzlFiu9zd1ngBoGn59 FSpJTBx5of8gNKg2jeXzJCOtk5fm0JBehKhs58Jfb0ype651tpwQlSGA+C+j3VPxEX6H 9+HhzQCApEnKlT6j/BmGlVKIcdRpGvhbFtU/YrujMN1TfXd5OvHdQecRR7MbafIYFb8w MxNXuHq/cPqfbUkfPACMgoduQ57Xk/G3pVmHfM3NS+8BnybIdFXcNxBTFZEeJAPy9zab G/qVJic/jILbU7XE4GTRIxU/4Hzfsm5zgJpeW85LHyQRRixTGOes/5NCN+lzIYb8sy+Y BJZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FBTrDXNWXY7ZPAJHB1q2pmYieIRphOe/mMSwCtpIV18=; b=a3/p9bC/6g3pRgr6P7mI9pUm61OaEPUIlPD3W4ZbkCdZwb1a8XISRZrF+/bBuPc9Bn o5Ur+gVWjuxNdfdXsCwruSYTRVR5+KI7McekLfSrtayMhlLdcEUtHXBetVfzkaVo+GnB 9NX2nIq1Da+cheEWo31N6o8BqlGkvybMglFHDQL96dtF83YMWv/Rehsuz/jevJ/zotGA oxzUAHbTTVBnjSiyda11kaDTCJNZJdcrLauK8/gxIyV2htzrEcXcMDrjOszupeMtMMaN RJc0DFlj8baJ/HDY+DIsUa29R4bX6klxrebr0LpbdR5OZ6ylm10gMc3yDZlP/TtYHloc jWjw== X-Gm-Message-State: AOAM533qbVL+Vh8L5fCvkS750qZhDPE6rbFDt06Q1IxlgXn6IqXsMVzG tltd0aTVv3MLdnIecvmm2yrv26vipw== X-Google-Smtp-Source: ABdhPJzOymvP0Ol7udGQa66VemBG2AZqN8jo517Qfd/xao9LvV1ecByGIMNpoi/Bw6kcQS5Ee35p4w== X-Received: by 2002:a17:90a:c295:: with SMTP id f21mr3813202pjt.208.1596198087313; Fri, 31 Jul 2020 05:21:27 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.21.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:26 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 03/16] mm,madvise: call soft_offline_page() without MF_COUNT_INCREASED Date: Fri, 31 Jul 2020 12:20:59 +0000 Message-Id: <20200731122112.11263-4-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: B771018086E24 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: From: Naoya Horiguchi The call to get_user_pages_fast is only to get the pointer to a struct page of a given address, pinning it is memory-poisoning handler's job, so drop the refcount grabbed by get_user_pages_fast(). Note that the target page is still pinned after this put_page() because the current process should have refcount from mapping. Signed-off-by: Naoya Horiguchi Signed-off-by: Oscar Salvador Reviewed-by: Mike Kravetz --- mm/madvise.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/madvise.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/madvise.c index a16dba21cdf6..1fe89a5b8d33 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/madvise.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/madvise.c @@ -910,16 +910,24 @@ static int madvise_inject_error(int behavior, */ size = page_size(compound_head(page)); - if (PageHWPoison(page)) { - put_page(page); + /* + * The get_user_pages_fast() is just to get the pfn of the + * given address, and the refcount has nothing to do with + * what we try to test, so it should be released immediately. + * This is racy but it's intended because the real hardware + * errors could happen at any moment and memory error handlers + * must properly handle the race. + */ + put_page(page); + + if (PageHWPoison(page)) continue; - } if (behavior == MADV_SOFT_OFFLINE) { pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", pfn, start); - ret = soft_offline_page(pfn, MF_COUNT_INCREASED); + ret = soft_offline_page(pfn, 0); if (ret) return ret; continue; @@ -927,14 +935,6 @@ static int madvise_inject_error(int behavior, pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", pfn, start); - - /* - * Drop the page reference taken by get_user_pages_fast(). In - * the absence of MF_COUNT_INCREASED the memory_failure() - * routine is responsible for pinning the page to prevent it - * from being released back to the page allocator. - */ - put_page(page); ret = memory_failure(pfn, 0); if (ret) return ret; From patchwork Fri Jul 31 12:21:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694833 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1C53913 for ; Fri, 31 Jul 2020 12:21:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AE2BA22B49 for ; Fri, 31 Jul 2020 12:21:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mL8mwKWQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE2BA22B49 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 872CC8D002B; Fri, 31 Jul 2020 08:21:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 822F48D002A; Fri, 31 Jul 2020 08:21:32 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C5588D002B; Fri, 31 Jul 2020 08:21:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 4FA4A8D002A for ; Fri, 31 Jul 2020 08:21:32 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 03C81180AD802 for ; Fri, 31 Jul 2020 12:21:32 +0000 (UTC) X-FDA: 77098281624.26.rat06_381545826f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id C56791804B640 for ; Fri, 31 Jul 2020 12:21:31 +0000 (UTC) X-Spam-Summary: 1,0,0,6e799614111fea10,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:968:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2898:2899:3138:3139:3140:3141:3142:3352:3876:3877:4321:5007:6114:6119:6261:6642:6653:6742:7576:7903:8603:9413:9592:10004:11026:11473:11658:11914:12043:12114:12297:12438:12517:12519:12555:12679:12740:12895:13069:13311:13357:14181:14384:14394:14721:21060:21080:21444:21627:21666:21990:22119:30003:30054:30070,0,RBL:209.85.216.65:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04yrfzqiq94q9g3jxzxn4dfhj3xgropo5xecqykrj5fdmpra6fusks4ft6htu65.r83pn7dgue4hbde9xfhz6trm1oabbb5gah9hqkot5tkhk4a7u4hk6yjbbddcqm7.c-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: rat06_381545826f83 X-Filterd-Recvd-Size: 4703 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:21:31 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id t15so7648294pjq.5 for ; Fri, 31 Jul 2020 05:21:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=C20rXtIxVYuV8kAt9ziq5r9X3XGDWqg/fkrphmJjKRQ=; b=mL8mwKWQzTvtX66d+UAyvZYdeQfelYFSjj9rVpvye6Z3Z69SI59FpRf6OxSdCEUyh0 1uV7DKEXrssFQAvdcBXZ3OPVVqRYmOyac7+wTTDLdr+Qz6hVv7vV6bwx9Cuyl0x+58ya Yog37R4NlqRmNjaj4HUv7O+CqxVQpBjIrkrNahCOWRl5Bkw+6rLYCG1SSEn4T8gmHLi2 T8tRatkzoVK9YvK4I4N2iskRZEB1mJN4IYFco0Zb6M/bc6/XrJ4TGATj2GeX2HykwvaI f1aIXZJ82amxGxC9ysOXv/8IUR4OArtjUM6WoKZayh72LgryYTd30z7JqrPLZcpm4X1J 5Fjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=C20rXtIxVYuV8kAt9ziq5r9X3XGDWqg/fkrphmJjKRQ=; b=TSv8SwIqEPW1529gyilMH9d2N0ClEKl3nLsLvDnyEtWxST1ynRNaDIZyyy+K/zTVQM slYapCmYBCeKGym3sN36Cp5y5O6XlOrln8Uf3NEmQm10Zhs6lverF6PNgyMl5v10RzcX FdljLRCUy2d4z2zP2pUET2WBpr873FDaNUPQSlbzB7u1HwzSE2CU31zwk9nylo+b73Dw jybmi+t1NRKtdPhPXUxN4IPOR5ms6pzspM7D+hYVXX4XQciVA+9Hz3BACWLJtmrSNwJP WDjOb+8MPHX6OJTD+8ACYSIzw8ZfH4RDyAqMVyKaoquAOTfv8CRGciVk5DIDmTEIZNFJ ZyVw== X-Gm-Message-State: AOAM533SPksyWBeAxISyhIcqm9ZC687TPEgjh3A1h+p6ciqHzOi1APi8 uq4lVUAGsh9fFXEqNk13SyA5mGG/Ew== X-Google-Smtp-Source: ABdhPJxBtp9vGmxG4kThIlaUgtwdMwKwb0g68uZr44relMDFK6s7Qp5rP4w+/RX5BF4lCvffoiwKlA== X-Received: by 2002:a63:3d06:: with SMTP id k6mr3577330pga.316.1596198090375; Fri, 31 Jul 2020 05:21:30 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:29 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 04/16] mm,madvise: Refactor madvise_inject_error Date: Fri, 31 Jul 2020 12:21:00 +0000 Message-Id: <20200731122112.11263-5-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: C56791804B640 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: From: Oscar Salvador Make a proper if-else condition for {hard,soft}-offline. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- mm/madvise.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/madvise.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/madvise.c index 1fe89a5b8d33..2c50c2c5673b 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/madvise.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/madvise.c @@ -886,16 +886,15 @@ static long madvise_remove(struct vm_area_struct *vma, static int madvise_inject_error(int behavior, unsigned long start, unsigned long end) { - struct page *page; struct zone *zone; unsigned long size; if (!capable(CAP_SYS_ADMIN)) return -EPERM; - for (; start < end; start += size) { unsigned long pfn; + struct page *page; int ret; ret = get_user_pages_fast(start, 1, 0, &page); @@ -925,17 +924,14 @@ static int madvise_inject_error(int behavior, if (behavior == MADV_SOFT_OFFLINE) { pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", - pfn, start); - + pfn, start); ret = soft_offline_page(pfn, 0); - if (ret) - return ret; - continue; + } else { + pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", + pfn, start); + ret = memory_failure(pfn, 0); } - pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", - pfn, start); - ret = memory_failure(pfn, 0); if (ret) return ret; } From patchwork Fri Jul 31 12:21:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694835 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFC62913 for ; Fri, 31 Jul 2020 12:21:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AC6F82087C for ; Fri, 31 Jul 2020 12:21:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ox0RjpA1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC6F82087C 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 989C08D002D; Fri, 31 Jul 2020 08:21:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8C1648D002C; Fri, 31 Jul 2020 08:21:35 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 787508D002D; Fri, 31 Jul 2020 08:21:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0218.hostedemail.com [216.40.44.218]) by kanga.kvack.org (Postfix) with ESMTP id 52F1A8D002C for ; Fri, 31 Jul 2020 08:21:35 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E6DDB3626 for ; Fri, 31 Jul 2020 12:21:34 +0000 (UTC) X-FDA: 77098281708.04.lunch46_3c0feb226f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id B6339800843E for ; Fri, 31 Jul 2020 12:21:34 +0000 (UTC) X-Spam-Summary: 1,0,0,2ad27dbf0f68d8e6,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:966:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2693:2899:3138:3139:3140:3141:3142:3353:3865:3867:3872:3874:4321:4385:5007:6119:6261:6653:6742:7576:7903:8957:9413:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12740:12895:13069:13311:13357:14181:14384:14394:14721:21060:21080:21094:21323:21444:21451:21627:21666:21990:22119:30054:30070,0,RBL:209.85.216.67:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04y8u9wbyrmjk6biok4aex663zdyzoccbp5i7uyqe1m89uyxaqwk7t55gyckrjo.siykxgt343d1xbor5hegareoks9mdo8b1akrpw5ixuritegs3mz4aamgjszp9c6.h-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: lunch46_3c0feb226f83 X-Filterd-Recvd-Size: 4996 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:21:34 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id e4so3976589pjd.0 for ; Fri, 31 Jul 2020 05:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=D4Ndr3lMfGWryT8BpcCBWbkT9Sd7Lw+5S6mzuxOjqm0=; b=Ox0RjpA12PJQHDITrdph5pOPcuN2GYXZFDP64O1Jg7Q9hHYJqG0b6qkA1DyLT1HCYA yAIAN9doa8ZzugIrAzEWwuyFfOELJ5kmOooR2FsMap3TbEF94piK1e/wcwC4z7k40eXD clWp0mC2ZCqtXIDvB1CzQ0PHfEixXvYcXb39QIxCU0XAIWo9nRhM6b8rAVWVSt4pdr1p CCpQPW7LRf5H85Yp258fUIC3WPDfZKKHL5AXw/yegUQzvD/xA1eFx09vK7HleoosgXCo DNp1KFajA6j0Re9O7hiQ0JAZ2xSIezel7P48RxdqtF86SMVg/VzFTdJLd/KqtpLARV4y RM5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=D4Ndr3lMfGWryT8BpcCBWbkT9Sd7Lw+5S6mzuxOjqm0=; b=duFVJP9hya8DQVjzR0ds4SiOo4BY1QnxWZVfc147c2st18KZ3/PvtrgizrThLmS3rd ZTiZTRotJZylfr3J+ln6DLAZg8ro43bTeD1q4K82+8FrF1ZpGz0Wn6CsadrUmddQW575 oBdiJTPtlo1BGtkUZzlaoTqxWCPgW2D0I1an4/+PGbi6PvGYk2RA/8YXHWPDtzeRTaew Dn75Q05tgregC5FIPSk9AJNaWEIcr1F4uyw5jLQlo2IO6SEPLrfbvuMELLE4hpCLxkWR R32jLJxa5qAxOinsLvglLrFWZiBOKlKiMLYtwJ4em5Yz0nXzyvTDg6zejuG1e0KfDuwk 63VA== X-Gm-Message-State: AOAM530mXsgQhqc/E2gjNxmEj4wkThLA/VdeuT10/qQDoNAVQZhXB+9G 1ksDsFhRtZjBdim7xZ8UOKpG20cfCA== X-Google-Smtp-Source: ABdhPJxsym233zotubkKtsT7WOGGC9czTkxCbghBK6umjx1A55M6pXrzAXib/Mcqh7ouG2Jv74/uoQ== X-Received: by 2002:a63:df03:: with SMTP id u3mr3359540pgg.84.1596198093503; Fri, 31 Jul 2020 05:21:33 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:33 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 05/16] mm,hwpoison-inject: don't pin for hwpoison_filter Date: Fri, 31 Jul 2020 12:21:01 +0000 Message-Id: <20200731122112.11263-6-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: B6339800843E X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: From: Naoya Horiguchi Another memory error injection interface debugfs:hwpoison/corrupt-pfn also takes bogus refcount for hwpoison_filter(). It's justified because this does a coarse filter, expecting that memory_failure() redoes the check for sure. Signed-off-by: Naoya Horiguchi Signed-off-by: Oscar Salvador --- mm/hwpoison-inject.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/hwpoison-inject.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/hwpoison-inject.c index e488876b168a..1ae1ebc2b9b1 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/hwpoison-inject.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/hwpoison-inject.c @@ -26,11 +26,6 @@ static int hwpoison_inject(void *data, u64 val) p = pfn_to_page(pfn); hpage = compound_head(p); - /* - * This implies unable to support free buddy pages. - */ - if (!get_hwpoison_page(p)) - return 0; if (!hwpoison_filter_enable) goto inject; @@ -40,23 +35,20 @@ static int hwpoison_inject(void *data, u64 val) * This implies unable to support non-LRU pages. */ if (!PageLRU(hpage) && !PageHuge(p)) - goto put_out; + return 0; /* - * do a racy check with elevated page count, to make sure PG_hwpoison - * will only be set for the targeted owner (or on a free page). + * do a racy check to make sure PG_hwpoison will only be set for + * the targeted owner (or on a free page). * memory_failure() will redo the check reliably inside page lock. */ err = hwpoison_filter(hpage); if (err) - goto put_out; + return 0; inject: pr_info("Injecting memory failure at pfn %#lx\n", pfn); - return memory_failure(pfn, MF_COUNT_INCREASED); -put_out: - put_hwpoison_page(p); - return 0; + return memory_failure(pfn, 0); } static int hwpoison_unpoison(void *data, u64 val) From patchwork Fri Jul 31 12:21:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694837 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 710FA1392 for ; Fri, 31 Jul 2020 12:21:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3D80021744 for ; Fri, 31 Jul 2020 12:21:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W7X53pQQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D80021744 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 3DF668D002F; Fri, 31 Jul 2020 08:21:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3677D8D002E; Fri, 31 Jul 2020 08:21:39 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 257278D002F; Fri, 31 Jul 2020 08:21:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0060.hostedemail.com [216.40.44.60]) by kanga.kvack.org (Postfix) with ESMTP id 0A6C68D002E for ; Fri, 31 Jul 2020 08:21:39 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9485A180AD802 for ; Fri, 31 Jul 2020 12:21:38 +0000 (UTC) X-FDA: 77098281876.11.worm33_550ebb426f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 68BD5180F8B86 for ; Fri, 31 Jul 2020 12:21:38 +0000 (UTC) X-Spam-Summary: 1,0,0,171b564c8b5496b3,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:355:379:541:800:960:968:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2899:3138:3139:3140:3141:3142:3352:3865:3867:3868:3870:3871:3872:3874:4321:5007:6261:6653:6742:7576:9413:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12740:12895:13069:13311:13357:14096:14181:14384:14394:14721:21060:21080:21444:21451:21627:21666:21795:21990:22119:30012:30051:30054,0,RBL:209.85.214.196:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yff9517sagyx4sptrqj65r6m4edyp77r64gictir67xxmqrnci4tb19mmrms8.o94qwn4pzeft48y3ew414c5rnsxwrpqnbebr9jcux651o8gbc393imfg6djecbu.n-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: worm33_550ebb426f83 X-Filterd-Recvd-Size: 4980 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:21:37 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id d1so17217787plr.8 for ; Fri, 31 Jul 2020 05:21:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CvFlC6ki86jyf2poLn8AnY/Z80LUaeq3pjN3kabbpGI=; b=W7X53pQQJeP+6wvSubGRknoAypUl4N+UBVvqYOwEY/No3tWTdwK68xvzzznrwy40+R YP1znazdj8HvaEpORWsDzOGZdjb7NsYU3uW7BSVD+KLnCxoIoVmzc7FQVxbg72IC4SKZ 2asMt27Y1lCGp/DtK6DECa4hGbzFXPOH+IODUQvXeZ8o6Ag/HFuNR0L21vfVRC8SNzbt OwHN40RmmaEaAjoR5q80yyO/Ye+k7k8ZIc93F9WYa8GaVpyUhIOodl8y6EPVFpfErhNu 301HErm59bsa0RoC7Wt1ns1hsZt4+i+goZz9CagUAASI1IPiVtGsPRVwwjn2ZtChDx+U 9MlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CvFlC6ki86jyf2poLn8AnY/Z80LUaeq3pjN3kabbpGI=; b=IfxpkrGA1WFhEFGYvig2fh60Sj07sYVkwrS7RNlxHjjMaXFiPCp+CJCIOHAZzRZVHk TRk1TfMXEd5WAWgv1zqoB2WPN0pdm9HbOYXVJK2hPunxMDznoNhESOo8rFhdEUU2TwVu HRwmzvYgv1I9E27dc08hvbRa3Ngv77aQJlUpzyikACuRcoBx4hSCKcocfaIr2Lw3TV1u +P6xEfFxz+v6YjO0kZuIZ4pg0RG7MX58O3YVTgdgCeYD2kHdVvpdrq5qnrsjKSeMRr7z w52O6/OvmWXQZZ/TLBODvQSuWsjL88O4PSXHahnsIt5Qy33gsmzQg55H7piGv9FOgcW3 qS7Q== X-Gm-Message-State: AOAM531mqf4SIlAVfRXYg4kfn6ArHXEi4QQuIID+PmptzE22iY52J2s9 3uicoVOxWmQRfD3NF+FkTuYr3vnrPQ== X-Google-Smtp-Source: ABdhPJywCCqceUPTuP1ChhjOjP9TuahX20BeNq3JsgzEUbx9EzjmcCEVHLLgUbOmChs8uDpXLd49Gg== X-Received: by 2002:a17:902:7c10:: with SMTP id x16mr3556236pll.122.1596198096570; Fri, 31 Jul 2020 05:21:36 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.21.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:36 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 06/16] mm,hwpoison: Un-export get_hwpoison_page and make it static Date: Fri, 31 Jul 2020 12:21:02 +0000 Message-Id: <20200731122112.11263-7-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 68BD5180F8B86 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: From: Oscar Salvador Since get_hwpoison_page is only used in memory-failure code now, let us un-export it and make it private to that code. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- include/linux/mm.h | 1 - mm/memory-failure.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/include/linux/mm.h v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/linux/mm.h index 5e76bb4291e6..8f742373a46a 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/include/linux/mm.h +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/linux/mm.h @@ -2985,7 +2985,6 @@ extern int memory_failure(unsigned long pfn, int flags); extern void memory_failure_queue(unsigned long pfn, int flags); extern void memory_failure_queue_kick(int cpu); extern int unpoison_memory(unsigned long pfn); -extern int get_hwpoison_page(struct page *page); #define put_hwpoison_page(page) put_page(page) extern int sysctl_memory_failure_early_kill; extern int sysctl_memory_failure_recovery; diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c index f8d200417e0f..405c9bef6ffb 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c @@ -925,7 +925,7 @@ static int page_action(struct page_state *ps, struct page *p, * Return: return 0 if failed to grab the refcount, otherwise true (some * non-zero value.) */ -int get_hwpoison_page(struct page *page) +static int get_hwpoison_page(struct page *page) { struct page *head = compound_head(page); @@ -954,7 +954,6 @@ int get_hwpoison_page(struct page *page) return 0; } -EXPORT_SYMBOL_GPL(get_hwpoison_page); /* * Do all that is necessary to remove user space mappings. Unmap From patchwork Fri Jul 31 12:21:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694839 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C32E913 for ; Fri, 31 Jul 2020 12:21:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0C7E82087C for ; Fri, 31 Jul 2020 12:21:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RHNMfYZ7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C7E82087C 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 E40F28D0031; Fri, 31 Jul 2020 08:21:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DCAAB8D0030; Fri, 31 Jul 2020 08:21:41 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C911B8D0031; Fri, 31 Jul 2020 08:21:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0002.hostedemail.com [216.40.44.2]) by kanga.kvack.org (Postfix) with ESMTP id A9AA38D0030 for ; Fri, 31 Jul 2020 08:21:41 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 688AF1EE6 for ; Fri, 31 Jul 2020 12:21:41 +0000 (UTC) X-FDA: 77098282002.28.dock78_3302a1626f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 378B46D72 for ; Fri, 31 Jul 2020 12:21:41 +0000 (UTC) X-Spam-Summary: 1,0,0,b491282316ff1cfe,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:2:41:69:355:379:541:800:960:966:973:988:989:1260:1345:1359:1437:1535:1606:1730:1747:1777:1792:2196:2199:2393:2559:2562:2899:2901:3138:3139:3140:3141:3142:3355:3867:3868:3871:3872:4119:4250:4321:4385:5007:6119:6261:6653:6742:7576:7903:8957:9413:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12683:12740:12895:14110:14394:21060:21080:21324:21444:21451:21627:21666:21990:22119:30054,0,RBL:209.85.214.194:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04y8p8kafxa8w5y35uazhs733ken5oczs6ucjrtnq3g8or79pijho3f95tqx8db.e3pz1ttkm3dg9koece5f98cioep88bi4jnycksxymxy7e5g4m66gmurm6z56h4u.o-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:1:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: dock78_3302a1626f83 X-Filterd-Recvd-Size: 8566 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:21:40 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id t10so11891821plz.10 for ; Fri, 31 Jul 2020 05:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OHzHoMnONnHgmQ6oS0LXj3evSeIK3rt+KuGRMSo863I=; b=RHNMfYZ7INmvkYdK1PdCI83KRYWH7DdU877VsMEzOud/rM+KMNB3vlyrgAbZ47hy9O LC9If1zMOiN7LX+uDhik8mYzZuJZePDM7vEdxrjzrkdsa010IKdYKoY8TdLW6K22l9+w MEc4nA5npneen3+FBqq0bFjnsF0SPCLBeHc22GwMp6nrvw39+Jad3UGOgAFsKULfXfnM EsWYACTOAhNQoXalpeK25eyYGlJDRLTlpQvLWYv0+6JjbkIlHJcnBpuDKdQlVe+9XC0p Sfdt8nfotLAOuyPujBdsjpHBTNekqBqqH6nV1gBDgyKmAbi2qqlw28pXQ7tIjBgVopII f//g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OHzHoMnONnHgmQ6oS0LXj3evSeIK3rt+KuGRMSo863I=; b=YW8o1s755TfGAP8jrxnxwzYZ0nFih+fzZhFrsJsogwukkOvC9x3aHsw4syQgpLi4uy oAIerZJTmiAaLTPcs9Wr4SayEov4B7mOsqbuXE6A4kOtr8TCixXCF4mCPNc0JxY29DEc m7fKRJRbv06TnMBF+0cNje6bUdxhu3RsVKC2rwymcyg+6j9rPXksdMB4WISkjEgKB0XY AlyKR3di+RfFIv21taHxIVQLF/mOvM/ZBERVd83vI8oOpI6gZHQ6Io7r824zlbB7UYsY Fr5fcPfB78ByX0MqVt4nunXn3JTFH9gmG+HWWJiMT6HADDdoWznTN1Tb9bxRzL66t+AO P2tw== X-Gm-Message-State: AOAM5305NbAyY2JZFK5vo9yyPpmDZbhDy+6L9vvEnwR8n3KBBlXwEEwB aaJjvRwHyRtHwIQgJcl22hYyUNfjog== X-Google-Smtp-Source: ABdhPJwYRz5kod3XCHjDVlzL6HDrI8a37sXmIaPl37+kb2V1Wyjx3zKLSM3wYhzIoZfP/orj4c6xXg== X-Received: by 2002:a63:531e:: with SMTP id h30mr3328177pgb.165.1596198099672; Fri, 31 Jul 2020 05:21:39 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.21.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:39 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 07/16] mm,hwpoison: Kill put_hwpoison_page Date: Fri, 31 Jul 2020 12:21:03 +0000 Message-Id: <20200731122112.11263-8-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 378B46D72 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: From: Oscar Salvador After commit 4e41a30c6d50 ("mm: hwpoison: adjust for new thp refcounting"), put_hwpoison_page got reduced to a put_page. Let us just use put_page instead. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- include/linux/mm.h | 1 - mm/memory-failure.c | 30 +++++++++++++++--------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/include/linux/mm.h v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/linux/mm.h index 8f742373a46a..371970dfffc4 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/include/linux/mm.h +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/linux/mm.h @@ -2985,7 +2985,6 @@ extern int memory_failure(unsigned long pfn, int flags); extern void memory_failure_queue(unsigned long pfn, int flags); extern void memory_failure_queue_kick(int cpu); extern int unpoison_memory(unsigned long pfn); -#define put_hwpoison_page(page) put_page(page) extern int sysctl_memory_failure_early_kill; extern int sysctl_memory_failure_recovery; extern void shake_page(struct page *p, int access); diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c index 405c9bef6ffb..6853bf3a253d 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c @@ -1144,7 +1144,7 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags) pr_err("Memory failure: %#lx: just unpoisoned\n", pfn); num_poisoned_pages_dec(); unlock_page(head); - put_hwpoison_page(head); + put_page(head); return 0; } @@ -1336,7 +1336,7 @@ int memory_failure(unsigned long pfn, int flags) pfn); if (TestClearPageHWPoison(p)) num_poisoned_pages_dec(); - put_hwpoison_page(p); + put_page(p); return -EBUSY; } unlock_page(p); @@ -1389,14 +1389,14 @@ int memory_failure(unsigned long pfn, int flags) pr_err("Memory failure: %#lx: just unpoisoned\n", pfn); num_poisoned_pages_dec(); unlock_page(p); - put_hwpoison_page(p); + put_page(p); return 0; } if (hwpoison_filter(p)) { if (TestClearPageHWPoison(p)) num_poisoned_pages_dec(); unlock_page(p); - put_hwpoison_page(p); + put_page(p); return 0; } @@ -1630,9 +1630,9 @@ int unpoison_memory(unsigned long pfn) } unlock_page(page); - put_hwpoison_page(page); + put_page(page); if (freeit && !(pfn == my_zero_pfn(0) && page_count(p) == 1)) - put_hwpoison_page(page); + put_page(page); return 0; } @@ -1683,7 +1683,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags) /* * Try to free it. */ - put_hwpoison_page(page); + put_page(page); shake_page(page, 1); /* @@ -1692,7 +1692,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags) ret = __get_any_page(page, pfn, 0); if (ret == 1 && !PageLRU(page)) { /* Drop page reference which is from __get_any_page() */ - put_hwpoison_page(page); + put_page(page); pr_info("soft_offline: %#lx: unknown non LRU page type %lx (%pGp)\n", pfn, page->flags, &page->flags); return -EIO; @@ -1715,7 +1715,7 @@ static int soft_offline_huge_page(struct page *page, int flags) lock_page(hpage); if (PageHWPoison(hpage)) { unlock_page(hpage); - put_hwpoison_page(hpage); + put_page(hpage); pr_info("soft offline: %#lx hugepage already poisoned\n", pfn); return -EBUSY; } @@ -1726,7 +1726,7 @@ static int soft_offline_huge_page(struct page *page, int flags) * get_any_page() and isolate_huge_page() takes a refcount each, * so need to drop one here. */ - put_hwpoison_page(hpage); + put_page(hpage); if (!ret) { pr_info("soft offline: %#lx hugepage failed to isolate\n", pfn); return -EBUSY; @@ -1779,7 +1779,7 @@ static int __soft_offline_page(struct page *page, int flags) wait_on_page_writeback(page); if (PageHWPoison(page)) { unlock_page(page); - put_hwpoison_page(page); + put_page(page); pr_info("soft offline: %#lx page already poisoned\n", pfn); return -EBUSY; } @@ -1794,7 +1794,7 @@ static int __soft_offline_page(struct page *page, int flags) * would need to fix isolation locking first. */ if (ret == 1) { - put_hwpoison_page(page); + put_page(page); pr_info("soft_offline: %#lx: invalidated\n", pfn); SetPageHWPoison(page); num_poisoned_pages_inc(); @@ -1814,7 +1814,7 @@ static int __soft_offline_page(struct page *page, int flags) * Drop page reference which is came from get_any_page() * successful isolate_lru_page() already took another one. */ - put_hwpoison_page(page); + put_page(page); if (!ret) { LIST_HEAD(pagelist); /* @@ -1858,7 +1858,7 @@ static int soft_offline_in_use_page(struct page *page, int flags) pr_info("soft offline: %#lx: non anonymous thp\n", page_to_pfn(page)); else pr_info("soft offline: %#lx: thp split failed\n", page_to_pfn(page)); - put_hwpoison_page(page); + put_page(page); return -EBUSY; } unlock_page(page); @@ -1931,7 +1931,7 @@ int soft_offline_page(unsigned long pfn, int flags) if (PageHWPoison(page)) { pr_info("soft offline: %#lx page already poisoned\n", pfn); if (flags & MF_COUNT_INCREASED) - put_hwpoison_page(page); + put_page(page); return -EBUSY; } From patchwork Fri Jul 31 12:21:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694841 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52446913 for ; Fri, 31 Jul 2020 12:21:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1F9A62087C for ; Fri, 31 Jul 2020 12:21:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sbKje5uI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F9A62087C 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 D55D18D0033; Fri, 31 Jul 2020 08:21:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CDE628D0032; Fri, 31 Jul 2020 08:21:44 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA6438D0033; Fri, 31 Jul 2020 08:21:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0085.hostedemail.com [216.40.44.85]) by kanga.kvack.org (Postfix) with ESMTP id 9D9308D0032 for ; Fri, 31 Jul 2020 08:21:44 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5F7DD1EE6 for ; Fri, 31 Jul 2020 12:21:44 +0000 (UTC) X-FDA: 77098282128.03.slope49_6206d9026f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 3218428A4E8 for ; Fri, 31 Jul 2020 12:21:44 +0000 (UTC) X-Spam-Summary: 1,0,0,110ae42838dec666,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:966:968:973:988:989:1260:1345:1359:1437:1535:1543:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2553:2559:2562:2899:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:3874:4117:4321:4385:5007:6261:6653:6742:7576:9010:9413:9592:10004:11026:11232:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12740:12895:13972:14093:14181:14394:14721:21060:21080:21444:21627:21666:21795:21939:21990:22119:30051:30054:30070:30090,0,RBL:209.85.214.194:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04yre3aib8xx7h9i9gp1dgoc9o7daoc7jzy8bb7kk9rmczufxshrdbs3wwejxya.hj1or6oddu1pth5a4upmgx797ci1wu3brwsqim54fead4tppiq595kg994pkz6o.n-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: slope49_6206d9026f83 X-Filterd-Recvd-Size: 6123 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:21:43 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id o1so17240853plk.1 for ; Fri, 31 Jul 2020 05:21:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LNtUR/zVIQaYBxFfor/p8rzccCbsJTTUqM4Vi3aweCQ=; b=sbKje5uIs6vCbwISQGSsY7ywCySYHLZXwGfBBzrrDlpKgZEwgXpkNnojXjn7XLjGP/ LCVVujswgi1kcKfAHve7pLUcRsbbTqELSBhvEYUW/53GDHRah+nKmDcVdOyNptggcte0 V3SW4VKwwje/98Hpyg8fTcf8q1o93Sg4eMBrrazVM2rqH79v8HW8x7qrDmwCC+ngDeSS ch8A6lSwj//OBO1B2xpREwfP/rmOxj82xg8rBvQQjx7geQJvQS5ZxCFkLL6dW/FCi506 m/rDix44wr2xoGqudd1ZNDA06C+fNSIJMkkHKMloNYydDjMPuZc2u+LIp64Yuur2h1pA RJ7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LNtUR/zVIQaYBxFfor/p8rzccCbsJTTUqM4Vi3aweCQ=; b=KaHZ55vIZHmFckV/GhS4e8c4PY1nEshk5cL209y9cFI9WjqcgiM5M3mzo43ZY/D0Tt RGHih+FFjx2A9N4NPIFQJ54CaoWZtS7GIdKBucTH0KOW3yaML/TGLSi+AIVPBIePOBNn ZgUEyaVfnifAveiFoKipwC4yamIAIBTTMhCJGSklML5FqZWaM4KYCMdy+5DxP3vsmjJd MpkSaP1NdvWV3lFGnV6wyLtvUOVbbWrevRXgX2cqBDFs7cbfnladTz2lVN9AgXSt2IsM ZPK7yxSB2q3hBNMQ52+Ojoo7m6hy66JsihFUp7eLTQ62irTlnaBambalN4oNrV34THZ2 kPug== X-Gm-Message-State: AOAM5324lc+BkxEltxajR2l5tzcMGy1ryrOOcLhCYGqDR2qz7+fKkQ/E yLmnnRTmQdqSLsesFO77PZhGtVc4WQ== X-Google-Smtp-Source: ABdhPJxYEpIrkMi6DnA+PXFhpdicTO+XfTlrSG7PPUPUyCZCiyePLqhVJJpOvhq2DRtPaUJItgn1AQ== X-Received: by 2002:a65:5c43:: with SMTP id v3mr3378625pgr.214.1596198102753; Fri, 31 Jul 2020 05:21:42 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.21.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:42 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 08/16] mm,hwpoison: remove MF_COUNT_INCREASED Date: Fri, 31 Jul 2020 12:21:04 +0000 Message-Id: <20200731122112.11263-9-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 3218428A4E8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: From: Naoya Horiguchi Now there's no user of MF_COUNT_INCREASED, so we can safely remove it from all calling points. Signed-off-by: Naoya Horiguchi Signed-off-by: Oscar Salvador --- include/linux/mm.h | 7 +++---- mm/memory-failure.c | 14 +++----------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/include/linux/mm.h v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/linux/mm.h index 371970dfffc4..c09111e8eac8 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/include/linux/mm.h +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/linux/mm.h @@ -2976,10 +2976,9 @@ void register_page_bootmem_memmap(unsigned long section_nr, struct page *map, unsigned long nr_pages); enum mf_flags { - MF_COUNT_INCREASED = 1 << 0, - MF_ACTION_REQUIRED = 1 << 1, - MF_MUST_KILL = 1 << 2, - MF_SOFT_OFFLINE = 1 << 3, + MF_ACTION_REQUIRED = 1 << 0, + MF_MUST_KILL = 1 << 1, + MF_SOFT_OFFLINE = 1 << 2, }; extern int memory_failure(unsigned long pfn, int flags); extern void memory_failure_queue(unsigned long pfn, int flags); diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c index 6853bf3a253d..9768ab5f51ef 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c @@ -1118,7 +1118,7 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags) num_poisoned_pages_inc(); - if (!(flags & MF_COUNT_INCREASED) && !get_hwpoison_page(p)) { + if (!get_hwpoison_page(p)) { /* * Check "filter hit" and "race with other subpage." */ @@ -1314,7 +1314,7 @@ int memory_failure(unsigned long pfn, int flags) * In fact it's dangerous to directly bump up page count from 0, * that may make page_ref_freeze()/page_ref_unfreeze() mismatch. */ - if (!(flags & MF_COUNT_INCREASED) && !get_hwpoison_page(p)) { + if (!get_hwpoison_page(p)) { if (is_free_buddy_page(p)) { action_result(pfn, MF_MSG_BUDDY, MF_DELAYED); return 0; @@ -1354,10 +1354,7 @@ int memory_failure(unsigned long pfn, int flags) shake_page(p, 0); /* shake_page could have turned it free. */ if (!PageLRU(p) && is_free_buddy_page(p)) { - if (flags & MF_COUNT_INCREASED) - action_result(pfn, MF_MSG_BUDDY, MF_DELAYED); - else - action_result(pfn, MF_MSG_BUDDY_2ND, MF_DELAYED); + action_result(pfn, MF_MSG_BUDDY_2ND, MF_DELAYED); return 0; } @@ -1648,9 +1645,6 @@ static int __get_any_page(struct page *p, unsigned long pfn, int flags) { int ret; - if (flags & MF_COUNT_INCREASED) - return 1; - /* * When the target page is a free hugepage, just remove it * from free hugepage list. @@ -1930,8 +1924,6 @@ int soft_offline_page(unsigned long pfn, int flags) if (PageHWPoison(page)) { pr_info("soft offline: %#lx page already poisoned\n", pfn); - if (flags & MF_COUNT_INCREASED) - put_page(page); return -EBUSY; } From patchwork Fri Jul 31 12:21:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694843 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 710D0913 for ; Fri, 31 Jul 2020 12:21:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 313F52087C for ; Fri, 31 Jul 2020 12:21:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BV/tk3/N" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 313F52087C 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 D2EBD8D0034; Fri, 31 Jul 2020 08:21:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CDE978D0032; Fri, 31 Jul 2020 08:21:47 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD7858D0034; Fri, 31 Jul 2020 08:21:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id A371A8D0032 for ; Fri, 31 Jul 2020 08:21:47 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 6A9D7181AEF0B for ; Fri, 31 Jul 2020 12:21:47 +0000 (UTC) X-FDA: 77098282254.24.neck79_330414426f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 473D01A4A0 for ; Fri, 31 Jul 2020 12:21:47 +0000 (UTC) X-Spam-Summary: 1,0,0,e495099aed4a2d3d,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:2:41:69:355:379:541:800:960:966:968:973:988:989:1260:1345:1359:1437:1535:1605:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:2899:2901:3138:3139:3140:3141:3142:3865:3866:3867:3868:3871:3872:3874:4049:4120:4321:4385:4470:4605:5007:6119:6261:6653:6742:7576:7875:7903:8957:9036:9413:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12740:12895:13146:13161:13229:13230:14394:21060:21080:21444:21611:21627:21666:21740:21990:22119:30003:30054,0,RBL:209.85.216.67:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04yrkriiddy4ntrb1yzd6q6ghgqugocotdoxo77zoawiwsox1ir1ycqax8heeym.mjkrhukrpxkawyerrc8brab3ynzrhnsdc165ir5axshi1wkn1kdzfe6trx1obnr.s-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:1:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: neck79_330414426f83 X-Filterd-Recvd-Size: 9341 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:21:46 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id a9so7213424pjd.3 for ; Fri, 31 Jul 2020 05:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lA5hCOOxKd5KS4DNVLZggsB4V0UYIUqby39pIHtSFTI=; b=BV/tk3/NZFWzExZRn1SNk7tn+RX5lXq4zgJHfljF+UZyR8OYlwQ6WhxoZ2W4CbKbU9 aIC0N8TApCCxG61ReuM8kE5yjMT7KNnfYMx3zoSmZxZCZt/y3QDWDInmmzoSmIAmAjxY 6beapW4QD1fMhzKwMQ/2kLJ+eDDX8ZweLWlU/LlkV30myri1cY89pl7W3pKotHX68L6s GTrw4xXg/cjTVRKp9/93GQ0ai6jIJhaNZwa5sDf433kChNZ2op392ccZjb4iwj3lmEQK ubOWHqeU+keYtczKSwizHhN5/KVI7+NY7YDtvkslJ0x4PZ252mwfywCjEVDfVb7zRggu pguA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lA5hCOOxKd5KS4DNVLZggsB4V0UYIUqby39pIHtSFTI=; b=bZVlS3x2RdbVjyVaJR0Sf/IAGnL6Gxri5kySiVHQdow0n+SpMq4qRIjK1kafj3CGAl qnutjlNDHxzXNJXRoxNy8s7Z6pmg+Xzdyt1auxuif1xjz2l0j82lG7LI8NKdu4YK25wZ jWFv8RTZmVf2EjpJWA+/lTLGoyGLyY7jCdIn5SuN0jMZHBjr/QCxmgVGLolp8bGCaKM0 3MYcXUXsjaEI+xobjQ96PooPZXnVvm+yFdNDuA+qpOh9xdF72yJpw9LlctXhqO7BujOE XMQn3FAFYDmDPZuyopu/W0iewORaAkrH4QUZTwxRtFQfZ7426nuc/vzstKnwTczV1bRU TGXA== X-Gm-Message-State: AOAM532G+bg7F7Y5Sz7O68+pjp2h14sX2rTi+ImE3BD3GKd5qIFEV5V9 To/UdPoRpNYu6xxXhWkN5Yar8XYm/w== X-Google-Smtp-Source: ABdhPJzctlZ9GdEehG92Jq22YQZVUDBLiYJqCJBNzg8O5fTbCmw7g1Trml4YTGAM11PZWaU48zurcA== X-Received: by 2002:a65:644d:: with SMTP id s13mr3554079pgv.103.1596198105836; Fri, 31 Jul 2020 05:21:45 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:45 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 09/16] mm,hwpoison: remove flag argument from soft offline functions Date: Fri, 31 Jul 2020 12:21:05 +0000 Message-Id: <20200731122112.11263-10-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 473D01A4A0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: From: Naoya Horiguchi The argument @flag no longer affects the behavior of soft_offline_page() and its variants, so let's remove them. Signed-off-by: Naoya Horiguchi Signed-off-by: Oscar Salvador --- drivers/base/memory.c | 2 +- include/linux/mm.h | 2 +- mm/madvise.c | 2 +- mm/memory-failure.c | 27 +++++++++++++-------------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/drivers/base/memory.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/drivers/base/memory.c index 4db3c660de83..3e6d27c9dff6 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/drivers/base/memory.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/drivers/base/memory.c @@ -463,7 +463,7 @@ static ssize_t soft_offline_page_store(struct device *dev, if (kstrtoull(buf, 0, &pfn) < 0) return -EINVAL; pfn >>= PAGE_SHIFT; - ret = soft_offline_page(pfn, 0); + ret = soft_offline_page(pfn); return ret == 0 ? count : ret; } diff --git v5.8-rc7-mmotm-2020-07-27-18-18/include/linux/mm.h v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/linux/mm.h index c09111e8eac8..ecb3c7191fb7 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/include/linux/mm.h +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/linux/mm.h @@ -2988,7 +2988,7 @@ extern int sysctl_memory_failure_early_kill; extern int sysctl_memory_failure_recovery; extern void shake_page(struct page *p, int access); extern atomic_long_t num_poisoned_pages __read_mostly; -extern int soft_offline_page(unsigned long pfn, int flags); +extern int soft_offline_page(unsigned long pfn); /* diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/madvise.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/madvise.c index 2c50c2c5673b..3eee78abdbec 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/madvise.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/madvise.c @@ -925,7 +925,7 @@ static int madvise_inject_error(int behavior, if (behavior == MADV_SOFT_OFFLINE) { pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", pfn, start); - ret = soft_offline_page(pfn, 0); + ret = soft_offline_page(pfn); } else { pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", pfn, start); diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c index 9768ab5f51ef..7c0a2f8cfe0c 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c @@ -1502,7 +1502,7 @@ static void memory_failure_work_func(struct work_struct *work) if (!gotten) break; if (entry.flags & MF_SOFT_OFFLINE) - soft_offline_page(entry.pfn, entry.flags); + soft_offline_page(entry.pfn); else memory_failure(entry.pfn, entry.flags); } @@ -1641,7 +1641,7 @@ EXPORT_SYMBOL(unpoison_memory); * that is not free, and 1 for any other page type. * For 1 the page is returned with increased page count, otherwise not. */ -static int __get_any_page(struct page *p, unsigned long pfn, int flags) +static int __get_any_page(struct page *p, unsigned long pfn) { int ret; @@ -1668,9 +1668,9 @@ static int __get_any_page(struct page *p, unsigned long pfn, int flags) return ret; } -static int get_any_page(struct page *page, unsigned long pfn, int flags) +static int get_any_page(struct page *page, unsigned long pfn) { - int ret = __get_any_page(page, pfn, flags); + int ret = __get_any_page(page, pfn); if (ret == 1 && !PageHuge(page) && !PageLRU(page) && !__PageMovable(page)) { @@ -1683,7 +1683,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags) /* * Did it turn free? */ - ret = __get_any_page(page, pfn, 0); + ret = __get_any_page(page, pfn); if (ret == 1 && !PageLRU(page)) { /* Drop page reference which is from __get_any_page() */ put_page(page); @@ -1695,7 +1695,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags) return ret; } -static int soft_offline_huge_page(struct page *page, int flags) +static int soft_offline_huge_page(struct page *page) { int ret; unsigned long pfn = page_to_pfn(page); @@ -1754,7 +1754,7 @@ static int soft_offline_huge_page(struct page *page, int flags) return ret; } -static int __soft_offline_page(struct page *page, int flags) +static int __soft_offline_page(struct page *page) { int ret; unsigned long pfn = page_to_pfn(page); @@ -1838,7 +1838,7 @@ static int __soft_offline_page(struct page *page, int flags) return ret; } -static int soft_offline_in_use_page(struct page *page, int flags) +static int soft_offline_in_use_page(struct page *page) { int ret; int mt; @@ -1868,9 +1868,9 @@ static int soft_offline_in_use_page(struct page *page, int flags) mt = get_pageblock_migratetype(page); set_pageblock_migratetype(page, MIGRATE_ISOLATE); if (PageHuge(page)) - ret = soft_offline_huge_page(page, flags); + ret = soft_offline_huge_page(page); else - ret = __soft_offline_page(page, flags); + ret = __soft_offline_page(page); set_pageblock_migratetype(page, mt); return ret; } @@ -1891,7 +1891,6 @@ static int soft_offline_free_page(struct page *page) /** * soft_offline_page - Soft offline a page. * @pfn: pfn to soft-offline - * @flags: flags. Same as memory_failure(). * * Returns 0 on success, otherwise negated errno. * @@ -1910,7 +1909,7 @@ static int soft_offline_free_page(struct page *page) * This is not a 100% solution for all memory, but tries to be * ``good enough'' for the majority of memory. */ -int soft_offline_page(unsigned long pfn, int flags) +int soft_offline_page(unsigned long pfn) { int ret; struct page *page; @@ -1928,11 +1927,11 @@ int soft_offline_page(unsigned long pfn, int flags) } get_online_mems(); - ret = get_any_page(page, pfn, flags); + ret = get_any_page(page, pfn); put_online_mems(); if (ret > 0) - ret = soft_offline_in_use_page(page, flags); + ret = soft_offline_in_use_page(page); else if (ret == 0) ret = soft_offline_free_page(page); From patchwork Fri Jul 31 12:21:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694845 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 522241392 for ; Fri, 31 Jul 2020 12:21:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1EB282087C for ; Fri, 31 Jul 2020 12:21:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XsLxJoNa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1EB282087C 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 C43248D0037; Fri, 31 Jul 2020 08:21:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BD09F8D0036; Fri, 31 Jul 2020 08:21:50 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A47EB8D0037; Fri, 31 Jul 2020 08:21:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id 87C598D0036 for ; Fri, 31 Jul 2020 08:21:50 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4D6AB8248047 for ; Fri, 31 Jul 2020 12:21:50 +0000 (UTC) X-FDA: 77098282380.09.drain96_621158926f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 24176180AD802 for ; Fri, 31 Jul 2020 12:21:50 +0000 (UTC) X-Spam-Summary: 1,0,0,fcdad90314e4fe49,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:2693:2899:3138:3139:3140:3141:3142:3353:3865:3866:3868:3870:3872:3874:4321:5007:6119:6120:6261:6653:6742:7576:7901:7903:8957:9413:10004:11026:11473:11658:11914:12043:12291:12296:12297:12438:12517:12519:12555:12679:12683:12740:12895:12986:14110:14181:14394:14721:21060:21080:21444:21627:21666:21990:22119:30012:30054,0,RBL:209.85.214.193:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04y83oagm3j1kwc3oz5atoy9s84fwocwjrruke9i1pnp3ghmwbn4a1ze9gbge51.164c5bwowsdcyqitcx3d58k9i8qs4nwzibz9ar1d6tacm4ghk9buprxcc57kdyd.o-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: drain96_621158926f83 X-Filterd-Recvd-Size: 5829 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:21:49 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id d1so17218229plr.8 for ; Fri, 31 Jul 2020 05:21:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xft2h5FohjfWqnBcTKXmA02wYQ8Sl17A7am29j5Mcz4=; b=XsLxJoNaCXyJMenZtH47jIDCecoY0NPI+oIT8mRxAwzFTQwvpVYtgrQmDqoCxZQS2j OkQkZGa3bB3lohBRuKB4KlRF1cx/nqhc0jF/j4qh/VIokvCJE/16aoZ5M9AZTi0NuXX3 ZVZOFHbJ9fQLxe5QccT/2LDXZuD33zVxYF4GPW5RRutWLf5Q9SES9ZTablJGOKNbEa0G 4rfMnwIjlYFSHvnXE10SIrnzcMOPyUJxusBJGs9YEXWBYjVEt0pfqwuMxr4KYzzUtQ3M n78Up05OOiIafcJ4Nm6qBQV/6LafOamSVbp03LF4yxx8MKuKXcUS6Bwsjbvhu0uaPTeD jhFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xft2h5FohjfWqnBcTKXmA02wYQ8Sl17A7am29j5Mcz4=; b=mA6wST391Mv9AnHBQyrSGXKTNwFDFWrD7zoRkz6Kum6oECUyNj+UmsnkEK8+NZ0dhX 7OhIdjLkEIxGWqWBk0zNcAbmwmvU8RY1req8ioJcYnSOiaNe702lN2Djz9lM89mGGlWY AsKBM1NXI14mfbAhuuLugQebcjmd4q53IoiTFJEcLprZ0ZLfXBPFxybmeMU80P0NDXox A0hDFjKn5IfYxaO4MDV/F6lo1+HpLTKZqKVuNMybtxi3j7Y+0sBbLPtNRTPO4Oq9NQnj e86cJq99bShXaivx7Fyd2YZtETRg/IjN6W2U6HiNeILUH6C3ItyKVRp6qi91p5wGWjnG AP/Q== X-Gm-Message-State: AOAM530Vt0O8phrSDoXUMKTcRS1gA7PU8m2nAHpqPeNuSuAsETrG/ypu VatZA/7WBP+bH6sYEs635XhOf2y2sQ== X-Google-Smtp-Source: ABdhPJyyOpZYacooGR5RU61olGUZyx0GrN1JXL6Y1g3Sx4pMqV32qBOed44LN62ckgW/2WaK7H+Lcw== X-Received: by 2002:a17:90b:4d0f:: with SMTP id mw15mr3787072pjb.174.1596198108893; Fri, 31 Jul 2020 05:21:48 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:48 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 10/16] mm,hwpoison: Unify THP handling for hard and soft offline Date: Fri, 31 Jul 2020 12:21:06 +0000 Message-Id: <20200731122112.11263-11-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 24176180AD802 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: From: Oscar Salvador Place the THP's page handling in a helper and use it from both hard and soft-offline machinery, so we get rid of some duplicated code. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 48 +++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 26 deletions(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c index 7c0a2f8cfe0c..803f4b2ac510 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c @@ -1103,6 +1103,25 @@ static int identify_page_state(unsigned long pfn, struct page *p, return page_action(ps, p, pfn); } +static int try_to_split_thp_page(struct page *page, const char *msg) +{ + lock_page(page); + if (!PageAnon(page) || unlikely(split_huge_page(page))) { + unsigned long pfn = page_to_pfn(page); + + unlock_page(page); + if (!PageAnon(page)) + pr_info("%s: %#lx: non anonymous thp\n", msg, pfn); + else + pr_info("%s: %#lx: thp split failed\n", msg, pfn); + put_page(page); + return -EBUSY; + } + unlock_page(page); + + return 0; +} + static int memory_failure_hugetlb(unsigned long pfn, int flags) { struct page *p = pfn_to_page(pfn); @@ -1325,21 +1344,8 @@ int memory_failure(unsigned long pfn, int flags) } if (PageTransHuge(hpage)) { - lock_page(p); - if (!PageAnon(p) || unlikely(split_huge_page(p))) { - unlock_page(p); - if (!PageAnon(p)) - pr_err("Memory failure: %#lx: non anonymous thp\n", - pfn); - else - pr_err("Memory failure: %#lx: thp split failed\n", - pfn); - if (TestClearPageHWPoison(p)) - num_poisoned_pages_dec(); - put_page(p); + if (try_to_split_thp_page(p, "Memory Failure") < 0) return -EBUSY; - } - unlock_page(p); VM_BUG_ON_PAGE(!page_count(p), p); } @@ -1844,19 +1850,9 @@ static int soft_offline_in_use_page(struct page *page) int mt; struct page *hpage = compound_head(page); - if (!PageHuge(page) && PageTransHuge(hpage)) { - lock_page(page); - if (!PageAnon(page) || unlikely(split_huge_page(page))) { - unlock_page(page); - if (!PageAnon(page)) - pr_info("soft offline: %#lx: non anonymous thp\n", page_to_pfn(page)); - else - pr_info("soft offline: %#lx: thp split failed\n", page_to_pfn(page)); - put_page(page); + if (!PageHuge(page) && PageTransHuge(hpage)) + if (try_to_split_thp_page(page, "soft offline") < 0) return -EBUSY; - } - unlock_page(page); - } /* * Setting MIGRATE_ISOLATE here ensures that the page will be linked From patchwork Fri Jul 31 12:21:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694847 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CAC48913 for ; Fri, 31 Jul 2020 12:21:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8E9CB22CF6 for ; Fri, 31 Jul 2020 12:21:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uz8VyDn0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E9CB22CF6 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 5DC238D003B; Fri, 31 Jul 2020 08:21:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 58B508D0038; Fri, 31 Jul 2020 08:21:54 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3DCF18D003B; Fri, 31 Jul 2020 08:21:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0187.hostedemail.com [216.40.44.187]) by kanga.kvack.org (Postfix) with ESMTP id 1F1448D0038 for ; Fri, 31 Jul 2020 08:21:54 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 9DFCC3626 for ; Fri, 31 Jul 2020 12:21:53 +0000 (UTC) X-FDA: 77098282506.16.act95_00096ba26f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 6BB29100E6924 for ; Fri, 31 Jul 2020 12:21:53 +0000 (UTC) X-Spam-Summary: 1,0,0,fb9ec8d268e2d59c,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:2:41:355:379:541:800:960:965:966:973:988:989:1260:1345:1359:1437:1535:1606:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:2693:2731:2898:2899:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:3874:4119:4321:4385:4390:4395:4421:4605:5007:6119:6261:6653:6742:7576:7875:7903:8603:8660:8957:9036:9413:9707:10004:11026:11232:11473:11658:11914:12043:12291:12296:12297:12438:12517:12519:12555:12679:12683:12740:12895:13148:13161:13229:13230:14096:14394:21060:21080:21094:21323:21444:21451:21627:21666:21939:21990:22119:30054:30070,0,RBL:209.85.214.193:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04yrhthyo1dedr6ck8s34pshobppgopxhyq5tqirpkfrwbhhaxd17193paz49d5.kiur1kgpxse1z86w1f4y48whnfnsu8ycktqufrtop4wmwd8jggs4wrshdyb9fph.s-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:non e,Custom X-HE-Tag: act95_00096ba26f83 X-Filterd-Recvd-Size: 8383 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:21:52 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id r4so6591789pls.2 for ; Fri, 31 Jul 2020 05:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AfC68d7kowdj1Po3j2eNcI6eI877xr95Yeb/gsIh8aA=; b=uz8VyDn0DSMwpxqa5V5r0k2Lr0QbardqpcV4k+YfGA/sra0EgnqjLw/7l6kHbD50aD A17TvzMuCG4hzEP2mxy0Jfu+6Os17uoQOKk7emeFZsvKaJgXaNnVjxL75v/lWGphHLr7 RuqUcQe/lsOKDO1xWedNWvZOOkH1jcD8HjAuc1R2umnS/tt+GSQ1KiI4tuQoSpP5xgYr YW7xYgIQm+G8JDArh1e+6I7VXm3xoyRXFIJGF2MGdR7kSbbMV03IsUbmaPa8QZOW5aho 4ppYa6kaG2fphE50CKH1k7szFANRmezKzAMCA+yg18A6urZpWi1j8Phz8kKfavAoDKj5 cWDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AfC68d7kowdj1Po3j2eNcI6eI877xr95Yeb/gsIh8aA=; b=NZKggfH+htnhldc6nyPalO5W+nV/1CnkxaerSj5++uE98lsBiKfHJvxbKfXfYO/+77 uwleBKBGTB2GQn2F2YmeKUmHvNZu0eCrgVKQH/nCPBzIEONcvCFQpz7eTkjZTJ6k/C6V kLmzhQNB3ezhafJzNkABnntB99JXbNm4Tn1aNtXjE+UKWcewgwGi6wu+v8T10Y8WB2uE sWjPFX4wQG4fb9JJlmUwhd8FlCFvp3dDTf51Q6yLyQGlpyzYcQ2uxMPwGxlikAC8dTAH Euxe9jIc6H4a26qFdaCxV8psi26JctGUUGL7GiVio6iJGfPZHFquAIXEuGpmi99eCQfE rlyw== X-Gm-Message-State: AOAM531aWKN8x7mpqjah5dIPLIdfzE4/0sQRGykoGKUgaV3iSVZoI9+o Z1nDM6S5h6Sv79VZVvjcfuF1nLWXqA== X-Google-Smtp-Source: ABdhPJwH/QssPRbVm1gWQ8BpCPSGvx2DbzMcjnLj2G2Ki5xoYTcQ+FNxavxRRSGDwJ4jQigRty9tIw== X-Received: by 2002:a62:c585:: with SMTP id j127mr3201614pfg.295.1596198111940; Fri, 31 Jul 2020 05:21:51 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.21.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:51 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 11/16] mm,hwpoison: Rework soft offline for free pages Date: Fri, 31 Jul 2020 12:21:07 +0000 Message-Id: <20200731122112.11263-12-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 6BB29100E6924 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: From: Oscar Salvador When trying to soft-offline a free page, we need to first take it off the buddy allocator. Once we know is out of reach, we can safely flag it as poisoned. take_page_off_buddy will be used to take a page meant to be poisoned off the buddy allocator. take_page_off_buddy calls break_down_buddy_pages, which splits a higher-order page in case our page belongs to one. Once the page is under our control, we call page_handle_poison to set it as poisoned and grab a refcount on it. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- ChangeLog v4 -> v5: - fix comile error ChangeLog v2 -> v3: - use add_to_free_list() instead of add_to_free_area() - use del_page_from_free_list() instead of del_page_from_free_area() - add fast return - move extern definition to header file as warned by checkpatch.pl --- include/linux/page-flags.h | 1 + mm/memory-failure.c | 18 ++++++---- mm/page_alloc.c | 68 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 6 deletions(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/include/linux/page-flags.h v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/linux/page-flags.h index 6be1aa559b1e..9fa5d4e2d69a 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/include/linux/page-flags.h +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/linux/page-flags.h @@ -423,6 +423,7 @@ PAGEFLAG(HWPoison, hwpoison, PF_ANY) TESTSCFLAG(HWPoison, hwpoison, PF_ANY) #define __PG_HWPOISON (1UL << PG_hwpoison) extern bool set_hwpoison_free_buddy_page(struct page *page); +extern bool take_page_off_buddy(struct page *page); #else PAGEFLAG_FALSE(HWPoison) static inline bool set_hwpoison_free_buddy_page(struct page *page) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c index 803f4b2ac510..8b6a98929b54 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c @@ -65,6 +65,13 @@ int sysctl_memory_failure_recovery __read_mostly = 1; atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0); +static void page_handle_poison(struct page *page) +{ + SetPageHWPoison(page); + page_ref_inc(page); + num_poisoned_pages_inc(); +} + #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE) u32 hwpoison_filter_enable = 0; @@ -1873,14 +1880,13 @@ static int soft_offline_in_use_page(struct page *page) static int soft_offline_free_page(struct page *page) { - int rc = dissolve_free_huge_page(page); + int rc = -EBUSY; - if (!rc) { - if (set_hwpoison_free_buddy_page(page)) - num_poisoned_pages_inc(); - else - rc = -EBUSY; + if (!dissolve_free_huge_page(page) && take_page_off_buddy(page)) { + page_handle_poison(page); + rc = 0; } + return rc; } diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/page_alloc.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/page_alloc.c index efe2e94c45f5..aab89f7db4ac 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/page_alloc.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/page_alloc.c @@ -8776,6 +8776,74 @@ bool is_free_buddy_page(struct page *page) } #ifdef CONFIG_MEMORY_FAILURE +/* + * Break down a higher-order page in sub-pages, and keep our target out of + * buddy allocator. + */ +static void break_down_buddy_pages(struct zone *zone, struct page *page, + struct page *target, int low, int high, + int migratetype) +{ + unsigned long size = 1 << high; + struct page *current_buddy, *next_page; + + while (high > low) { + high--; + size >>= 1; + + if (target >= &page[size]) { + next_page = page + size; + current_buddy = page; + } else { + next_page = page; + current_buddy = page + size; + } + + if (set_page_guard(zone, current_buddy, high, migratetype)) + continue; + + if (current_buddy != target) { + add_to_free_list(current_buddy, zone, high, migratetype); + set_page_order(current_buddy, high); + page = next_page; + } + } +} + +/* + * Take a page that will be marked as poisoned off the buddy allocator. + */ +bool take_page_off_buddy(struct page *page) +{ + struct zone *zone = page_zone(page); + unsigned long pfn = page_to_pfn(page); + unsigned long flags; + unsigned int order; + bool ret = false; + + spin_lock_irqsave(&zone->lock, flags); + for (order = 0; order < MAX_ORDER; order++) { + struct page *page_head = page - (pfn & ((1 << order) - 1)); + int buddy_order = page_order(page_head); + + if (PageBuddy(page_head) && buddy_order >= order) { + unsigned long pfn_head = page_to_pfn(page_head); + int migratetype = get_pfnblock_migratetype(page_head, + pfn_head); + + del_page_from_free_list(page_head, zone, buddy_order); + break_down_buddy_pages(zone, page_head, page, 0, + buddy_order, migratetype); + ret = true; + break; + } + if (page_count(page_head) > 0) + break; + } + spin_unlock_irqrestore(&zone->lock, flags); + return ret; +} + /* * Set PG_hwpoison flag if a given page is confirmed to be a free page. This * test is performed under the zone lock to prevent a race against page From patchwork Fri Jul 31 12:21:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694849 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F78B913 for ; Fri, 31 Jul 2020 12:21:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C32C922D02 for ; Fri, 31 Jul 2020 12:21:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R2Irg0mG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C32C922D02 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 64F4D8D0041; Fri, 31 Jul 2020 08:21:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5D8B98D0040; Fri, 31 Jul 2020 08:21:57 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A3C78D0041; Fri, 31 Jul 2020 08:21:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0070.hostedemail.com [216.40.44.70]) by kanga.kvack.org (Postfix) with ESMTP id 2B5EA8D0040 for ; Fri, 31 Jul 2020 08:21:57 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E43F0181AEF10 for ; Fri, 31 Jul 2020 12:21:56 +0000 (UTC) X-FDA: 77098282632.14.cap89_0a178c526f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id B85CC18229837 for ; Fri, 31 Jul 2020 12:21:56 +0000 (UTC) X-Spam-Summary: 1,0,0,ac8795bf40c5ce1c,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:1:2:41:69:355:379:541:800:960:966:973:988:989:1260:1345:1359:1437:1605:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:2693:2731:2899:3138:3139:3140:3141:3142:3865:3866:3867:3868:3870:3871:3872:3874:4052:4250:4321:4385:4605:5007:6119:6261:6653:6742:7576:7875:7903:8660:8957:9010:9413:9592:9707:10004:11026:11232:11473:11658:11914:12043:12257:12296:12297:12438:12517:12519:12555:12679:12683:12740:12895:12986:13148:13230:14096:14394:21060:21080:21094:21220:21323:21324:21444:21451:21627:21666:21740:21795:21939:21987:21990:22119:30012:30051:30054:30070:30083:30091,0,RBL:209.85.214.196:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04y8jji979317x9f7ee4zexfgpamfyc3ansuh58mddimdngm6dz7n14jgi765sh.5664hymf4o3jezx3nxrdsn757xyph5ufw5i9s9y74ty4udxqwiycj4z1ugit9k8.k-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk ,SPF:fp, X-HE-Tag: cap89_0a178c526f83 X-Filterd-Recvd-Size: 12658 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:21:56 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id o1so17241338plk.1 for ; Fri, 31 Jul 2020 05:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pt4wZRPPT9vGjmHQV1VDNs43Psj/uaJUUJf7X/E4ezU=; b=R2Irg0mGuyMq7RfPWSo9p4sPmWsu6MEC0u8ce7tj8Z6dmLWpzsc6x4M1emu1jU5wvf FQ4JDGsTXwcF+MeCov8oUNIqgdZ0JPazdjPEjLJvCZ/WYWsY/Symwqw606iIQ5lXSvmJ gZbfOxyTgR3zOgnhuyQkVC60RnZQVvkAnohDH0EUv7SetJllZVEblpg+eFv78GFPXMGn Y4F2fTUj2pNixY/5j/ivhVa0ogmkbcDu81oU/ovZm/jvPYMZXHN9wU/YquVojBQWIX8L wvnT1xgDm7T0GTC8GwgDFLT4k1x+7nq31zPhi9Y7E5HdaK1P4GAM/UuSgYnsqY7x6O4B aJVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pt4wZRPPT9vGjmHQV1VDNs43Psj/uaJUUJf7X/E4ezU=; b=KETvcSPO6voVaPrBneETFb78JV156x6+H3ONMIvGp/P00+SyZczkM9DJAFrJyvWAfi piyyI49xqWLeQUpJeotsXu7N1yU0ziSXmxHC118L3w2sRYZTWy05qAeQVhfh50Rj/2P1 RrlJy98zTLVq/oKB7Cbl3QmkD2AksW1qU1chK0LClwcfhiJZAOg1KPjC9b7d07OJXrot hxBN2STKkTuBfIQh200ykMqlGVkZrG7+tVdyvBd3RqLLFduwaFI6Y3BjAM2ZzT+KfoLs C+qBPPjZLplf/oFGII/pLetw6VwlyeMIajxvJYmwytq+DVWZ1md0OLmiHRZJngeYu5xb lABw== X-Gm-Message-State: AOAM530/9qG1jDyQbJiao5OXwB3omZmI2I30eG2XHeyLwXG7QhvIy7Fn g2mchP6dCfAzewt7zh6WctL3SxsNbA== X-Google-Smtp-Source: ABdhPJzmVW85iaJttJIO9sXSSD5MoyEzACrNrLfeFaV+W3NKZEZ3xECYvTJIjjZ+cdPIvOuVcgD9uw== X-Received: by 2002:a63:e23:: with SMTP id d35mr3348034pgl.435.1596198115009; Fri, 31 Jul 2020 05:21:55 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:54 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 12/16] mm,hwpoison: Rework soft offline for in-use pages Date: Fri, 31 Jul 2020 12:21:08 +0000 Message-Id: <20200731122112.11263-13-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: B85CC18229837 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: From: Oscar Salvador This patch changes the way we set and handle in-use poisoned pages. Until now, poisoned pages were released to the buddy allocator, trusting that the checks that take place prior to hand the page would act as a safe net and would skip that page. This has proved to be wrong, as we got some pfn walkers out there, like compaction, that all they care is the page to be PageBuddy and be in a freelist. Although this might not be the only user, having poisoned pages in the buddy allocator seems a bad idea as we should only have free pages that are ready and meant to be used as such. Before explaining the taken approach, let us break down the kind of pages we can soft offline. - Anonymous THP (after the split, they end up being 4K pages) - Hugetlb - Order-0 pages (that can be either migrated or invalited) * Normal pages (order-0 and anon-THP) - If they are clean and unmapped page cache pages, we invalidate then by means of invalidate_inode_page(). - If they are mapped/dirty, we do the isolate-and-migrate dance. Either way, do not call put_page directly from those paths. Instead, we keep the page and send it to page_set_poison to perform the right handling. page_set_poison sets the HWPoison flag and does the last put_page. This call to put_page is mainly to be able to call __page_cache_release, since this function is not exported. Down the chain, we placed a check for HWPoison page in free_pages_prepare, that just skips any poisoned page, so those pages do not end up in any pcplist/freelist. After that, we set the refcount on the page to 1 and we increment the poisoned pages counter. We could do as we do for free pages: 1) wait until the page hits buddy's freelists 2) take it off 3) flag it The problem is that we could race with an allocation, so by the time we want to take the page off the buddy, the page is already allocated, so we cannot soft-offline it. This is not fatal of course, but if it is better if we can close the race as does not require a lot of code. * Hugetlb pages - We isolate-and-migrate them After the migration has been successful, we call dissolve_free_huge_page, and we set HWPoison on the page if we succeed. Hugetlb has a slightly different handling though. While for non-hugetlb pages we cared about closing the race with an allocation, doing so for hugetlb pages requires quite some additional code (we would need to hook in free_huge_page and some other places). So I decided to not make the code overly complicated and just fail normally if the page we allocated in the meantime. Because of the way we handle now in-use pages, we no longer need the put-as-isolation-migratetype dance, that was guarding for poisoned pages to end up in pcplists. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- include/linux/page-flags.h | 5 ----- mm/memory-failure.c | 45 ++++++++++++++------------------------ mm/migrate.c | 11 +++------- mm/page_alloc.c | 28 ------------------------ 4 files changed, 19 insertions(+), 70 deletions(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/include/linux/page-flags.h v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/linux/page-flags.h index 9fa5d4e2d69a..d1df51ed6eeb 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/include/linux/page-flags.h +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/linux/page-flags.h @@ -422,14 +422,9 @@ PAGEFLAG_FALSE(Uncached) PAGEFLAG(HWPoison, hwpoison, PF_ANY) TESTSCFLAG(HWPoison, hwpoison, PF_ANY) #define __PG_HWPOISON (1UL << PG_hwpoison) -extern bool set_hwpoison_free_buddy_page(struct page *page); extern bool take_page_off_buddy(struct page *page); #else PAGEFLAG_FALSE(HWPoison) -static inline bool set_hwpoison_free_buddy_page(struct page *page) -{ - return 0; -} #define __PG_HWPOISON 0 #endif diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c index 8b6a98929b54..291084e27ead 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c @@ -65,8 +65,12 @@ int sysctl_memory_failure_recovery __read_mostly = 1; atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0); -static void page_handle_poison(struct page *page) +static void page_handle_poison(struct page *page, bool release) { + if (release) { + put_page(page); + drain_all_pages(page_zone(page)); + } SetPageHWPoison(page); page_ref_inc(page); num_poisoned_pages_inc(); @@ -1750,19 +1754,13 @@ static int soft_offline_huge_page(struct page *page) ret = -EIO; } else { /* - * We set PG_hwpoison only when the migration source hugepage - * was successfully dissolved, because otherwise hwpoisoned - * hugepage remains on free hugepage list, then userspace will - * find it as SIGBUS by allocation failure. That's not expected - * in soft-offlining. + * We set PG_hwpoison only when we were able to take the page + * off the buddy. */ - ret = dissolve_free_huge_page(page); - if (!ret) { - if (set_hwpoison_free_buddy_page(page)) - num_poisoned_pages_inc(); - else - ret = -EBUSY; - } + if (!dissolve_free_huge_page(page) && take_page_off_buddy(page)) + page_handle_poison(page, false); + else + ret = -EBUSY; } return ret; } @@ -1801,10 +1799,8 @@ static int __soft_offline_page(struct page *page) * would need to fix isolation locking first. */ if (ret == 1) { - put_page(page); pr_info("soft_offline: %#lx: invalidated\n", pfn); - SetPageHWPoison(page); - num_poisoned_pages_inc(); + page_handle_poison(page, true); return 0; } @@ -1835,7 +1831,9 @@ static int __soft_offline_page(struct page *page) list_add(&page->lru, &pagelist); ret = migrate_pages(&pagelist, alloc_migration_target, NULL, (unsigned long)&mtc, MIGRATE_SYNC, MR_MEMORY_FAILURE); - if (ret) { + if (!ret) { + page_handle_poison(page, true); + } else { if (!list_empty(&pagelist)) putback_movable_pages(&pagelist); @@ -1854,27 +1852,16 @@ static int __soft_offline_page(struct page *page) static int soft_offline_in_use_page(struct page *page) { int ret; - int mt; struct page *hpage = compound_head(page); if (!PageHuge(page) && PageTransHuge(hpage)) if (try_to_split_thp_page(page, "soft offline") < 0) return -EBUSY; - /* - * Setting MIGRATE_ISOLATE here ensures that the page will be linked - * to free list immediately (not via pcplist) when released after - * successful page migration. Otherwise we can't guarantee that the - * page is really free after put_page() returns, so - * set_hwpoison_free_buddy_page() highly likely fails. - */ - mt = get_pageblock_migratetype(page); - set_pageblock_migratetype(page, MIGRATE_ISOLATE); if (PageHuge(page)) ret = soft_offline_huge_page(page); else ret = __soft_offline_page(page); - set_pageblock_migratetype(page, mt); return ret; } @@ -1883,7 +1870,7 @@ static int soft_offline_free_page(struct page *page) int rc = -EBUSY; if (!dissolve_free_huge_page(page) && take_page_off_buddy(page)) { - page_handle_poison(page); + page_handle_poison(page, false); rc = 0; } diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/migrate.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/migrate.c index 2c809ffcf0e1..d7a9379c343b 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/migrate.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/migrate.c @@ -1222,16 +1222,11 @@ static int unmap_and_move(new_page_t get_new_page, * we want to retry. */ if (rc == MIGRATEPAGE_SUCCESS) { - put_page(page); - if (reason == MR_MEMORY_FAILURE) { + if (reason != MR_MEMORY_FAILURE) /* - * Set PG_HWPoison on just freed page - * intentionally. Although it's rather weird, - * it's how HWPoison flag works at the moment. + * We release the page in page_handle_poison. */ - if (set_hwpoison_free_buddy_page(page)) - num_poisoned_pages_inc(); - } + put_page(page); } else { if (rc != -EAGAIN) { if (likely(!__PageMovable(page))) { diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/page_alloc.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/page_alloc.c index aab89f7db4ac..e4896e674594 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/page_alloc.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/page_alloc.c @@ -8843,32 +8843,4 @@ bool take_page_off_buddy(struct page *page) spin_unlock_irqrestore(&zone->lock, flags); return ret; } - -/* - * Set PG_hwpoison flag if a given page is confirmed to be a free page. This - * test is performed under the zone lock to prevent a race against page - * allocation. - */ -bool set_hwpoison_free_buddy_page(struct page *page) -{ - struct zone *zone = page_zone(page); - unsigned long pfn = page_to_pfn(page); - unsigned long flags; - unsigned int order; - bool hwpoisoned = false; - - spin_lock_irqsave(&zone->lock, flags); - for (order = 0; order < MAX_ORDER; order++) { - struct page *page_head = page - (pfn & ((1 << order) - 1)); - - if (PageBuddy(page_head) && page_order(page_head) >= order) { - if (!TestSetPageHWPoison(page)) - hwpoisoned = true; - break; - } - } - spin_unlock_irqrestore(&zone->lock, flags); - - return hwpoisoned; -} #endif From patchwork Fri Jul 31 12:21:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694851 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F02D913 for ; Fri, 31 Jul 2020 12:22:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E245C2177B for ; Fri, 31 Jul 2020 12:22:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XB3ceEtK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E245C2177B 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 7D7A28D0048; Fri, 31 Jul 2020 08:22:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 75F988D0047; Fri, 31 Jul 2020 08:22:00 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 601F88D0048; Fri, 31 Jul 2020 08:22:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0088.hostedemail.com [216.40.44.88]) by kanga.kvack.org (Postfix) with ESMTP id 3BCD88D0047 for ; Fri, 31 Jul 2020 08:22:00 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E5433180AD802 for ; Fri, 31 Jul 2020 12:21:59 +0000 (UTC) X-FDA: 77098282758.27.beds77_0e1768126f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id B37E43D668 for ; Fri, 31 Jul 2020 12:21:59 +0000 (UTC) X-Spam-Summary: 1,0,0,77774a9763b8862b,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:1:2:41:69:355:379:541:800:960:966:973:982:988:989:1260:1345:1359:1437:1605:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:2693:2731:2899:3138:3139:3140:3141:3142:3865:3866:3867:3868:3870:3871:3872:3874:4052:4250:4321:4385:5007:6119:6261:6653:6742:7576:7875:7903:8957:9010:9413:9592:11026:11232:11473:11658:11914:12043:12114:12291:12296:12297:12438:12517:12519:12555:12679:12683:12740:12895:13180:13229:13255:14096:14394:21060:21080:21094:21220:21323:21324:21444:21451:21627:21666:21740:21939:21987:21990:22119:30012:30034:30054:30070,0,RBL:209.85.216.49:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04yff6mc973589remkiiaeugju7d6ocbk45giedu8ct6oemf97w5cwkwtnpd16i.grz7dxq3q3m3utimxdqdr3m86meiy6urpcb333pwmh19oxanfxtbf1rkdgrhg1b.e-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,C ustom_ru X-HE-Tag: beds77_0e1768126f83 X-Filterd-Recvd-Size: 12283 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:21:59 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id lx9so7654276pjb.2 for ; Fri, 31 Jul 2020 05:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QPlYUvjeWvVBL7eDA2nj80d0sGUhuKmjuwt8TTwVLow=; b=XB3ceEtKeY5H0BjkXQ37Y9Hzzljzt+occHiPIBtgviD9f36lJftXuB8XwjANaqvQuk oSw005EB2A29R1jpV2j+vMFVukOI+3ZkqHoWqtHW1UN6M0WyWmHajr2JIcGmCbCwf626 QP2V0UKtQfe4GZUT5zQzziOU3krN5Q/NDnaahCa9nl6tkvOKOiKs56WdBBrffyJzCPbJ Rr5rnskzsjTWAhJTeqTl0JmIU3BdIx/8siQ88ygwNA9Z5dk6eGJBKa9SpnFQXrmAbuCG A6Kdb3ncSplGXAQCqoAL0UVVzMsMq6cwdvGLON6+KVC5uDAVSv/O7L6LWRo/eBo4CxoT sa7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QPlYUvjeWvVBL7eDA2nj80d0sGUhuKmjuwt8TTwVLow=; b=RW+YwHb64h/xB8G2OM5PTX2bgTCPaxloAMIHZCu3JlNcaR9teaI9kEdCFulVg+08B6 0K1KsGudpenH6E0oYdLCxwo7k3pOqK+dlXAOn4kGZhYjVLwy1KNcwEn1qG2ipGw+RJgf mdJ7+A/LhMCm2CG5sEWglPnwJGcRs7BBE07RJeduqItPcwIwKfitV/xjaRk5Sm4tgbt8 Sz+0FUElE4Yja/9h1mmuJat8X7oUVj5oWHGY3thCLYAFyIxz9aXxPDA08GKoU4PPdtjP SHJdXI4bew5bZrDdUBbZZ+zPv9x5T1kfDTsFzccGIoOXpsDUPxnldV7JLibzES/aS13s njdA== X-Gm-Message-State: AOAM532IzAq0WMsxFGETRw0Y9r5aZ9xC4MkXvOIw9gdp4pKDA6WFbeSc ah67TvBlWzERDwjjGdLkSmAd/dRZeA== X-Google-Smtp-Source: ABdhPJzCgOZxNhkOz6v7ITO/5ijG4IHOgYTdeRbIc4Ulqfc5wi7veJkR1RGeu/hjJORoAogP7ZH0UA== X-Received: by 2002:a17:90b:11c4:: with SMTP id gv4mr3769770pjb.198.1596198118096; Fri, 31 Jul 2020 05:21:58 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.21.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:57 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 13/16] mm,hwpoison: Refactor soft_offline_huge_page and __soft_offline_page Date: Fri, 31 Jul 2020 12:21:09 +0000 Message-Id: <20200731122112.11263-14-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: B37E43D668 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: From: Oscar Salvador Merging soft_offline_huge_page and __soft_offline_page let us get rid of quite some duplicated code, and makes the code much easier to follow. Now, __soft_offline_page will handle both normal and hugetlb pages. Note that move put_page() block to the beginning of page_handle_poison() with drain_all_pages() in order to make sure that the target page is freed and sent into free list to make take_page_off_buddy() work properly. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- ChangeLog v4 -> v5: - use "char const *msg_page[]" instead of "const char *msg_page[]" - move adding drain_all_pages() to 12/16 ChangeLog v2 -> v3: - use page_is_file_lru() instead of page_is_file_cache(), - add description about put_page() and drain_all_pages(). - fix coding style warnings by checkpatch.pl --- mm/memory-failure.c | 177 ++++++++++++++++++++------------------------ 1 file changed, 80 insertions(+), 97 deletions(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c index 291084e27ead..904dec64da6b 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c @@ -65,15 +65,33 @@ int sysctl_memory_failure_recovery __read_mostly = 1; atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0); -static void page_handle_poison(struct page *page, bool release) +static bool page_handle_poison(struct page *page, bool hugepage_or_freepage, bool release) { if (release) { put_page(page); drain_all_pages(page_zone(page)); } + + if (hugepage_or_freepage) { + /* + * Doing this check for free pages is also fine since dissolve_free_huge_page + * returns 0 for non-hugetlb pages as well. + */ + if (dissolve_free_huge_page(page) || !take_page_off_buddy(page)) + /* + * We could fail to take off the target page from buddy + * for example due to racy page allocaiton, but that's + * acceptable because soft-offlined page is not broken + * and if someone really want to use it, they should + * take it. + */ + return false; + } + SetPageHWPoison(page); page_ref_inc(page); num_poisoned_pages_inc(); + return true; } #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE) @@ -1712,63 +1730,52 @@ static int get_any_page(struct page *page, unsigned long pfn) return ret; } -static int soft_offline_huge_page(struct page *page) +static bool isolate_page(struct page *page, struct list_head *pagelist) { - int ret; - unsigned long pfn = page_to_pfn(page); - struct page *hpage = compound_head(page); - LIST_HEAD(pagelist); + bool isolated = false; + bool lru = PageLRU(page); + + if (PageHuge(page)) { + isolated = isolate_huge_page(page, pagelist); + } else { + if (lru) + isolated = !isolate_lru_page(page); + else + isolated = !isolate_movable_page(page, ISOLATE_UNEVICTABLE); + + if (isolated) + list_add(&page->lru, pagelist); - /* - * This double-check of PageHWPoison is to avoid the race with - * memory_failure(). See also comment in __soft_offline_page(). - */ - lock_page(hpage); - if (PageHWPoison(hpage)) { - unlock_page(hpage); - put_page(hpage); - pr_info("soft offline: %#lx hugepage already poisoned\n", pfn); - return -EBUSY; } - unlock_page(hpage); - ret = isolate_huge_page(hpage, &pagelist); + if (isolated && lru) + inc_node_page_state(page, NR_ISOLATED_ANON + + page_is_file_lru(page)); + /* - * get_any_page() and isolate_huge_page() takes a refcount each, - * so need to drop one here. + * If we succeed to isolate the page, we grabbed another refcount on + * the page, so we can safely drop the one we got from get_any_pages(). + * If we failed to isolate the page, it means that we cannot go further + * and we will return an error, so drop the reference we got from + * get_any_pages() as well. */ - put_page(hpage); - if (!ret) { - pr_info("soft offline: %#lx hugepage failed to isolate\n", pfn); - return -EBUSY; - } - - ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL, - MIGRATE_SYNC, MR_MEMORY_FAILURE); - if (ret) { - pr_info("soft offline: %#lx: hugepage migration failed %d, type %lx (%pGp)\n", - pfn, ret, page->flags, &page->flags); - if (!list_empty(&pagelist)) - putback_movable_pages(&pagelist); - if (ret > 0) - ret = -EIO; - } else { - /* - * We set PG_hwpoison only when we were able to take the page - * off the buddy. - */ - if (!dissolve_free_huge_page(page) && take_page_off_buddy(page)) - page_handle_poison(page, false); - else - ret = -EBUSY; - } - return ret; + put_page(page); + return isolated; } +/* + * __soft_offline_page handles hugetlb-pages and non-hugetlb pages. + * If the page is a non-dirty unmapped page-cache page, it simply invalidates. + * If the page is mapped, it migrates the contents over. + */ static int __soft_offline_page(struct page *page) { - int ret; + int ret = 0; unsigned long pfn = page_to_pfn(page); + struct page *hpage = compound_head(page); + char const *msg_page[] = {"page", "hugepage"}; + bool huge = PageHuge(page); + LIST_HEAD(pagelist); struct migration_target_control mtc = { .nid = NUMA_NO_NODE, .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, @@ -1781,98 +1788,74 @@ static int __soft_offline_page(struct page *page) * so there's no race between soft_offline_page() and memory_failure(). */ lock_page(page); - wait_on_page_writeback(page); + if (!PageHuge(page)) + wait_on_page_writeback(page); if (PageHWPoison(page)) { unlock_page(page); put_page(page); pr_info("soft offline: %#lx page already poisoned\n", pfn); return -EBUSY; } - /* - * Try to invalidate first. This should work for - * non dirty unmapped page cache pages. - */ - ret = invalidate_inode_page(page); + + if (!PageHuge(page)) + /* + * Try to invalidate first. This should work for + * non dirty unmapped page cache pages. + */ + ret = invalidate_inode_page(page); unlock_page(page); + /* * RED-PEN would be better to keep it isolated here, but we * would need to fix isolation locking first. */ - if (ret == 1) { + if (ret) { pr_info("soft_offline: %#lx: invalidated\n", pfn); - page_handle_poison(page, true); + page_handle_poison(page, false, true); return 0; } - /* - * Simple invalidation didn't work. - * Try to migrate to a new page instead. migrate.c - * handles a large number of cases for us. - */ - if (PageLRU(page)) - ret = isolate_lru_page(page); - else - ret = isolate_movable_page(page, ISOLATE_UNEVICTABLE); - /* - * Drop page reference which is came from get_any_page() - * successful isolate_lru_page() already took another one. - */ - put_page(page); - if (!ret) { - LIST_HEAD(pagelist); - /* - * After isolated lru page, the PageLRU will be cleared, - * so use !__PageMovable instead for LRU page's mapping - * cannot have PAGE_MAPPING_MOVABLE. - */ - if (!__PageMovable(page)) - inc_node_page_state(page, NR_ISOLATED_ANON + - page_is_file_lru(page)); - list_add(&page->lru, &pagelist); + if (isolate_page(hpage, &pagelist)) { ret = migrate_pages(&pagelist, alloc_migration_target, NULL, (unsigned long)&mtc, MIGRATE_SYNC, MR_MEMORY_FAILURE); if (!ret) { - page_handle_poison(page, true); + bool release = !huge; + + if (!page_handle_poison(page, true, release)) + ret = -EBUSY; } else { if (!list_empty(&pagelist)) putback_movable_pages(&pagelist); - pr_info("soft offline: %#lx: migration failed %d, type %lx (%pGp)\n", - pfn, ret, page->flags, &page->flags); + + pr_info("soft offline: %#lx: %s migration failed %d, type %lx (%pGp)\n", + pfn, msg_page[huge], ret, page->flags, &page->flags); if (ret > 0) ret = -EIO; } } else { - pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx (%pGp)\n", - pfn, ret, page_count(page), page->flags, &page->flags); + pr_info("soft offline: %#lx: %s isolation failed: %d, page count %d, type %lx (%pGp)\n", + pfn, msg_page[huge], ret, page_count(page), page->flags, &page->flags); } return ret; } static int soft_offline_in_use_page(struct page *page) { - int ret; struct page *hpage = compound_head(page); if (!PageHuge(page) && PageTransHuge(hpage)) if (try_to_split_thp_page(page, "soft offline") < 0) return -EBUSY; - - if (PageHuge(page)) - ret = soft_offline_huge_page(page); - else - ret = __soft_offline_page(page); - return ret; + return __soft_offline_page(page); } static int soft_offline_free_page(struct page *page) { - int rc = -EBUSY; + int rc = 0; - if (!dissolve_free_huge_page(page) && take_page_off_buddy(page)) { - page_handle_poison(page, false); - rc = 0; - } + if (!page_handle_poison(page, true, false)) + rc = -EBUSY; return rc; } From patchwork Fri Jul 31 12:21:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694853 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12CF51392 for ; Fri, 31 Jul 2020 12:22:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C919B2087C for ; Fri, 31 Jul 2020 12:22:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kCcvCqps" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C919B2087C 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 53E3C8D004A; Fri, 31 Jul 2020 08:22:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4C9A38D0049; Fri, 31 Jul 2020 08:22:03 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 345D58D004A; Fri, 31 Jul 2020 08:22:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 125E08D0049 for ; Fri, 31 Jul 2020 08:22:03 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C536C181AEF10 for ; Fri, 31 Jul 2020 12:22:02 +0000 (UTC) X-FDA: 77098282884.04.maid90_460316a26f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 97F79800843D for ; Fri, 31 Jul 2020 12:22:02 +0000 (UTC) X-Spam-Summary: 1,0,0,4e1eac9255474711,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1535:1542:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2693:2898:2899:3138:3139:3140:3141:3142:3353:3865:3867:3868:3870:3871:3872:3874:4321:4605:5007:6119:6261:6653:6742:7576:7903:8957:9121:9413:9592:10004:11026:11233:11473:11658:11914:12043:12297:12438:12517:12519:12555:12679:12740:12895:13166:13229:13255:14181:14394:14721:21060:21080:21324:21444:21627:21666:21795:21990:22119:30003:30054:30070,0,RBL:209.85.216.65:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04y8bpsiohx5a81bzseomwtf4idyropwufk344gf34umukd8ucjubrdu3grpa3r.jnt5yzqfs54khiydrbsqgdhkb3qup5amw3dosa49rp7pycrd37913rwzio6kknu.1-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: maid90_460316a26f83 X-Filterd-Recvd-Size: 5527 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:22:02 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id t6so3814349pjr.0 for ; Fri, 31 Jul 2020 05:22:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WtOEWqIWk9JjcgYbtTh/VY54dSMQGk3haQqeS7NhWEU=; b=kCcvCqpsvoDrNqbbF1qDxUJ0N2OqrNTvt1A+Pumffkxof23yXR2h2++hDtJO8v3+MO EI6ZHkh5XbtZezFwk1btqfeBTj8LFSQo2lA/BHPGJbH1tcKIOTje9nV4zXLHOCM3sPoO WKzKq/lB3CQ4ExGLRfTQp9Xt7ARE4dZqkszoVq6WvFqeO5CldcZWfaA409/I98IaBJvI zPaGvjwR+uIW8Rge+vf8QYP6GpD7zRnLVD+AIIvGxBg0rqGC0DJ+JrR/0o3gRIqaxDsz +0c8k1q86E2N5X8jmk7kDleDuI7dmKKPjlJ7yjk+TojGEPbGT1hURQsNRgPUEANbxSZX B8JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WtOEWqIWk9JjcgYbtTh/VY54dSMQGk3haQqeS7NhWEU=; b=Sm53yS2Pw1Up03xJ0B5BRDv/edKYlA46WV31FlyjnmXo4c+jq7iaSxQm/bg0H467JN udp5TcwX2Y0z6aRjFckItOEwP5zNEyqWd/W4vACkNMjBTS6R0j0jUXR0eV9c+cjrNMki SENHEz/T30KHdpmoZN39LxmHqkDqXzEQ2Zixj0rKmwZaJGO4ja/2WJFaZB+wue84Xm7p 0fF9rlyy9x8eewfJbNGJ3Thgo/WIgTAXbGfXyg93BidKtD2jiPxQqbqQSxDgqxeZZIYQ 8iT1YmiWfiKo9knqVhYuzYn2vYMdqLyoXRXzKn05t4wCzj5X7jfo6yZWq54EqryCFw1Q r25Q== X-Gm-Message-State: AOAM530DXZQMI7vRAxUhVmovQjewwlIS2Otf6SCXuiU940dGGjJ1B0Xf t0lPIMxodOHQRcrWwGgx+ANJK7gODQ== X-Google-Smtp-Source: ABdhPJx5uVsf47BpfzXr8xTEgB/mU5aV20nGmkRnVlJdXZhe6/OTqDHY+RruvzRyJLF6G3+IkBf3Gw== X-Received: by 2002:a65:6650:: with SMTP id z16mr3667397pgv.161.1596198121188; Fri, 31 Jul 2020 05:22:01 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.21.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:22:00 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 14/16] mm,hwpoison: Return 0 if the page is already poisoned in soft-offline Date: Fri, 31 Jul 2020 12:21:10 +0000 Message-Id: <20200731122112.11263-15-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 97F79800843D X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: From: Oscar Salvador Currently, there is an inconsistency when calling soft-offline from different paths on a page that is already poisoned. 1) madvise: madvise_inject_error skips any poisoned page and continues the loop. If that was the only page to madvise, it returns 0. 2) /sys/devices/system/memory/: When calling soft_offline_page_store()->soft_offline_page(), we return -EBUSY in case the page is already poisoned. This is inconsistent with a) the above example and b) memory_failure, where we return 0 if the page was poisoned. Fix this by dropping the PageHWPoison() check in madvise_inject_error, and let soft_offline_page return 0 if it finds the page already poisoned. Please, note that this represents a user-api change, since now the return error when calling soft_offline_page_store()->soft_offline_page() will be different. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- mm/madvise.c | 3 --- mm/memory-failure.c | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/madvise.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/madvise.c index 3eee78abdbec..843f6fad3b89 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/madvise.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/madvise.c @@ -919,9 +919,6 @@ static int madvise_inject_error(int behavior, */ put_page(page); - if (PageHWPoison(page)) - continue; - if (behavior == MADV_SOFT_OFFLINE) { pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", pfn, start); diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c index 904dec64da6b..bd63f1f2e44e 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c @@ -1794,7 +1794,7 @@ static int __soft_offline_page(struct page *page) unlock_page(page); put_page(page); pr_info("soft offline: %#lx page already poisoned\n", pfn); - return -EBUSY; + return 0; } if (!PageHuge(page)) @@ -1895,7 +1895,7 @@ int soft_offline_page(unsigned long pfn) if (PageHWPoison(page)) { pr_info("soft offline: %#lx page already poisoned\n", pfn); - return -EBUSY; + return 0; } get_online_mems(); From patchwork Fri Jul 31 12:21:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694855 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E5FB1392 for ; Fri, 31 Jul 2020 12:22:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DF9A022D3E for ; Fri, 31 Jul 2020 12:22:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JH0YS43k" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF9A022D3E 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 714118D004C; Fri, 31 Jul 2020 08:22:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 69F668D004B; Fri, 31 Jul 2020 08:22:06 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56A4D8D004C; Fri, 31 Jul 2020 08:22:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0027.hostedemail.com [216.40.44.27]) by kanga.kvack.org (Postfix) with ESMTP id 3A6EC8D004B for ; Fri, 31 Jul 2020 08:22:06 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 01D528248047 for ; Fri, 31 Jul 2020 12:22:06 +0000 (UTC) X-FDA: 77098283052.25.mine37_580097e26f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id C904E1804E3A1 for ; Fri, 31 Jul 2020 12:22:05 +0000 (UTC) X-Spam-Summary: 1,0,0,3a459b1130f16d48,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1345:1359:1437:1535:1543:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2899:3138:3139:3140:3141:3142:3353:3867:3871:3872:3874:4117:4250:4321:4385:4605:5007:6261:6653:6742:7576:8660:8957:9413:10004:11026:11473:11658:11914:12043:12297:12438:12517:12519:12555:12679:12740:12895:13148:13230:14093:14181:14394:14721:21060:21080:21094:21212:21323:21324:21444:21627:21666:21939:21990:22119:30054,0,RBL:209.85.216.65:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04ygfdzo4xjd77ghnp1pmrafryndpycoa4ndhgoh9mb5acijhfn45kj73tpwnqy.afzw44egmck9mj3f1frwgfm4fe6wywczasiawkcujrphg9iqat3yiq415qx6q6j.a-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: mine37_580097e26f83 X-Filterd-Recvd-Size: 6063 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:22:05 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id e22so7655985pjt.3 for ; Fri, 31 Jul 2020 05:22:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DeQp8qeoPbySHXWwwb0orjOK+38VoyYyRVxT40RVsgA=; b=JH0YS43kMG6lFBe3wbbXVA15iWByJHoFD+/phhTMfrNmROe8y/ANMlG9BW6mVewofq 19uCSvVxVUC1JOxMvD6nCVqHq/J0GeqfsQ0jTvtv2mBHRmck4fseevfjtTnBn2OTVqi2 jehg04UOdaFl7OBA8YPi0UadKkF112L0v/p6TypyL4MG+P9928qmJxa1t+wbs5iWZP8K DuXNuvXkG0pwHYtkhD6kak4x8nsBXiS3ly9eX1E2r5gZmI4i28R0hSOmjkB6wTRZkl7i 6lBgPKg+a53bdGyt0FmFZ7ZTHzDpkYIgZwEfx2dTqJxgqFDFVjsb9K3rFEe9pZEclSRt F2Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DeQp8qeoPbySHXWwwb0orjOK+38VoyYyRVxT40RVsgA=; b=a4psqbMKXc1zum67acAXDCvFa/3LHGqRwujyepsSmOkoWNjbKLoGgrPR3yGD/4M/br WwUPlU5Zu0jj4kxXWtLm0BVtoQEFu5cb5kFbDgfBotM49Shvs2chG1DhCW0wWXgIPMCA axzxobizDMMjzhkdBGzJUDyYEEaQDiPxKW9z323PrDdlenxBDnTRrJcGnl7e/Mo1ax0D OrjrmBOxT4ZalKkzSupfXpEs5jmMsN/YC5/LBY5DGmoFuDaXqNCd6Qe+DvRoGVkprVRy Qsq4OMFqFzVYCAprqaYIZ4AzPsdeBFsyVj8MPXklciIDj4+jfhePuLgZldcGCR1+891l pJOA== X-Gm-Message-State: AOAM532qmI4tc+wOynv18yzZCy5qJcQYCB876/u1jpI7vDRDzclEIn53 W8d1HDX38xWAPDdZbXlGjV10ZQa+fw== X-Google-Smtp-Source: ABdhPJxCuhOPlrzcVhXzPFCZw2q0er+jAX8DvkrMnB02bNmSP9JC8tnUAqk7NPyCj/LrVkCYpYd0VQ== X-Received: by 2002:a17:90a:3fc7:: with SMTP id u7mr3784062pjm.231.1596198124242; Fri, 31 Jul 2020 05:22:04 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id m19sm3675692pjv.34.2020.07.31.05.22.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:22:03 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 15/16] mm,hwpoison: introduce MF_MSG_UNSPLIT_THP Date: Fri, 31 Jul 2020 12:21:11 +0000 Message-Id: <20200731122112.11263-16-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: C904E1804E3A1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: From: Naoya Horiguchi memory_failure() is supposed to call action_result() when it handles a memory error event, but there's one missing case. So let's add it. I find that include/ras/ras_event.h has some other MF_MSG_* undefined, so this patch also adds them. Signed-off-by: Naoya Horiguchi Signed-off-by: Oscar Salvador --- include/linux/mm.h | 1 + include/ras/ras_event.h | 3 +++ mm/memory-failure.c | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/include/linux/mm.h v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/linux/mm.h index ecb3c7191fb7..4f12b2465e80 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/include/linux/mm.h +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/linux/mm.h @@ -3023,6 +3023,7 @@ enum mf_action_page_type { MF_MSG_BUDDY, MF_MSG_BUDDY_2ND, MF_MSG_DAX, + MF_MSG_UNSPLIT_THP, MF_MSG_UNKNOWN, }; diff --git v5.8-rc7-mmotm-2020-07-27-18-18/include/ras/ras_event.h v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/ras/ras_event.h index 36c5c5e38c1d..0bdbc0d17d2f 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/include/ras/ras_event.h +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/include/ras/ras_event.h @@ -361,6 +361,7 @@ TRACE_EVENT(aer_event, EM ( MF_MSG_POISONED_HUGE, "huge page already hardware poisoned" ) \ EM ( MF_MSG_HUGE, "huge page" ) \ EM ( MF_MSG_FREE_HUGE, "free huge page" ) \ + EM ( MF_MSG_NON_PMD_HUGE, "non-pmd-sized huge page" ) \ EM ( MF_MSG_UNMAP_FAILED, "unmapping failed page" ) \ EM ( MF_MSG_DIRTY_SWAPCACHE, "dirty swapcache page" ) \ EM ( MF_MSG_CLEAN_SWAPCACHE, "clean swapcache page" ) \ @@ -373,6 +374,8 @@ TRACE_EVENT(aer_event, EM ( MF_MSG_TRUNCATED_LRU, "already truncated LRU page" ) \ EM ( MF_MSG_BUDDY, "free buddy page" ) \ EM ( MF_MSG_BUDDY_2ND, "free buddy page (2nd try)" ) \ + EM ( MF_MSG_DAX, "dax page" ) \ + EM ( MF_MSG_UNSPLIT_THP, "unsplit thp" ) \ EMe ( MF_MSG_UNKNOWN, "unknown page" ) /* diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c index bd63f1f2e44e..6f242a194c64 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c @@ -583,6 +583,7 @@ static const char * const action_page_types[] = { [MF_MSG_BUDDY] = "free buddy page", [MF_MSG_BUDDY_2ND] = "free buddy page (2nd try)", [MF_MSG_DAX] = "dax page", + [MF_MSG_UNSPLIT_THP] = "unsplit thp", [MF_MSG_UNKNOWN] = "unknown page", }; @@ -1373,8 +1374,10 @@ int memory_failure(unsigned long pfn, int flags) } if (PageTransHuge(hpage)) { - if (try_to_split_thp_page(p, "Memory Failure") < 0) + if (try_to_split_thp_page(p, "Memory Failure") < 0) { + action_result(pfn, MF_MSG_UNSPLIT_THP, MF_IGNORED); return -EBUSY; + } VM_BUG_ON_PAGE(!page_count(p), p); }