From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F17AC433DF 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 C230F206C0 for ; Wed, 24 Jun 2020 15:02:31 +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 C230F206C0 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) Received: by kanga.kvack.org (Postfix, from userid 40) id 671926B000D; Wed, 24 Jun 2020 11:02:31 -0400 (EDT) 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-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-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; -- 2.17.1