From patchwork Wed Jun 24 15:01:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623371 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 7F3FA60D for ; Wed, 24 Jun 2020 15:02:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 42E1B206C0 for ; Wed, 24 Jun 2020 15:02:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZbkXzDYE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42E1B206C0 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 6C14F6B000C; Wed, 24 Jun 2020 11:02:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 671926B000D; Wed, 24 Jun 2020 11:02:31 -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 588766B000E; Wed, 24 Jun 2020 11:02:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0115.hostedemail.com [216.40.44.115]) by kanga.kvack.org (Postfix) with ESMTP id 437C66B000C for ; Wed, 24 Jun 2020 11:02:31 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 08E663499 for ; Wed, 24 Jun 2020 15:02:31 +0000 (UTC) X-FDA: 76964421702.20.group14_540e6f926e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 20FAD180C01A8 for ; Wed, 24 Jun 2020 15:01:58 +0000 (UTC) X-Spam-Summary: 30,2,0,db2c8dd7cb56a9d1,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:7576:7903:8603:8660:9413:9592:10010:11026:11473:11658:11914:12043:12297:12438:12517:12519:12555:12679:12740:12895:12986:13148:13161:13180:13229:13230:13255:14181:14394:14721:21060:21080:21212:21444:21627:21666:21740:21939:21987:21990:22119:30003:30054:30070:30091,0,RBL:209.85.210.196:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yfihe85rxep9pgjkd8zg77imgtfypu793m87189scyqewyuow151jihspduec.x1a5ffg61gc7msn3qw31ua8esqt1bxbxdzmzjw16buzua4rkojsygcozeefntzr.q-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:28,LUA_SUMMARY:none X-HE-Tag: group14_540e6f926e45 X-Filterd-Recvd-Size: 5323 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:01:53 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id q17so1270849pfu.8 for ; Wed, 24 Jun 2020 08:01:53 -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=FEJYjJlKBMyCMGijANDJfuAtwxDZBaJxFe8PT9k9lOo=; b=ZbkXzDYEzJAUOuoSuEPzDu3T3s2ANCIzdd/mnQhx9cIhkexxmXPyqUiKUS0a04gkLc ClQ0zVIPoY4JTr7mLz6mRIb8GiZoAVbF9I7BvuHTjg+TlIaSj0diBgyscF9vB0ylPykx kwqNGGo2RxBMxs2ql8yN1S/VO248AAynV4rRRkp6mPFiGVsnLhSME7GPaDAgnpzM22Ig dxYphPIbWdhtdDe42x2jNvAUP5hAyT9KuNQvqG2pJ8Br08sS0MHuW1mWtUoYg5PfnHS3 MDa6suSQy8rwoX8axAXr4u5hNRw3Q5EcIkgi6fdkxsfQ1BZCAh6j39GhJSQLsLV+4IaX ellA== 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=FEJYjJlKBMyCMGijANDJfuAtwxDZBaJxFe8PT9k9lOo=; b=niz7eg4mHfhKCxAEDonhMtwzgzvmDBOSNeTVQOru/kGsK4Pgy/v3RlsAnN0kbbSS7U eGzU3Lq+y2TMaftdWs6ENAtqof1P568E5ac8yfi8AWDZTdfxkvm6jeu3VSxIDk6AhYHt xdupqnodVZ2iUUO+S32j/uXDgnmCwG/Ux4LbOFOwPBvHjI8aMeTTR88bkNW0qdo7epwx Ia6yS/a05049buHr3MU1mwE+VzSZBBq7Ro2z1hT8EPGE0wehOUqSaxemzQgl6U/tBdBO sXmQiWuDevNic3OChXHBKxjCEwkcd7gnbknfPvV+WfDSuJqqcycPg2UTjGgmNXGLMQNR AMOg== X-Gm-Message-State: AOAM530zndsId3olCBTNnEyZBrrq+zNR77JxzXZL5NHg3A0ZCaj8f88o PqpKzSzmBpr8SOsVT41aNTOszpy9Lg== X-Google-Smtp-Source: ABdhPJwRW8kdDe1v0yNB7iBTcXkFJNL6srZLU4fAx0l+FGJaNBYFg+WuLETuG1PxD12B9E7UFzlNAA== X-Received: by 2002:aa7:8147:: with SMTP id d7mr8105744pfn.29.1593010911771; Wed, 24 Jun 2020 08:01: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 i125sm17013705pgd.21.2020.06.24.08.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:01: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, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 03/15] mm,madvise: call soft_offline_page() without MF_COUNT_INCREASED Date: Wed, 24 Jun 2020 15:01:25 +0000 Message-Id: <20200624150137.7052-4-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 20FAD180C01A8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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 --- mm/madvise.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/madvise.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/madvise.c index dd1d43cf026d..275b08edd428 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/madvise.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/madvise.c @@ -893,16 +893,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; @@ -910,14 +918,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;