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;