Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp651896ybt; Wed, 24 Jun 2020 08:02:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcBWlHwSvXh/k5tOsVDUVf37Vb43DQKJGSAiXWl8f+9nhopULrwPfXgR2811o3ENp89GOB X-Received: by 2002:a17:906:4310:: with SMTP id j16mr24164775ejm.511.1593010975483; Wed, 24 Jun 2020 08:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593010975; cv=none; d=google.com; s=arc-20160816; b=qmJppM7Kio17Gmc5WJHZf0RI283HgE/BdWG3RppDCDIqssZkpX9zGP/pSKUuZZSMQ+ n3iTNguTE4fFp/1DcOYbXzGvK5tOg4r36veBTrRSqpNa67l/yNb3fd1dpBKyHmbHxJOW XWUQb7zCT/E4mEb1ykl8FiEnRqO+kp3uxyh7mHa3rmVASpQqK3OGNqAMip3iVO6VAPZm 1vcySGbvl0QLybMTqMUfFuYm3zOfyK3bfRXGU7K1niGVsfcjzxl0OWcQ33csZR3TZmIr vDl68ovSQSOlHGbxNYWMnHdJwQGfBYB9q15+Yn7xkk/B/z8nVLfRqHKelZhLePYQ7RMj +NkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=FEJYjJlKBMyCMGijANDJfuAtwxDZBaJxFe8PT9k9lOo=; b=ZYK6k2IE2nC5lkvAH4mt7+6BMu6v4OxDh4czNa6sMkWiU4upn4V9yZobrksnlh22Cd ihVfn4vxFx7fpu8WyN3wyE+B/FhbuYJ6G7MevZRk9YXS4yZBsDZE374GWjzWcmae4Ou9 QBDSEE8HomKbcpEwC2QVyZXCFEHMoPvBkCsIJJy+ysRQvPWWHEgEZ/eVNB6Jb+NbH/Et SCgoloSPLIelQXSdjq8PMp2hCbdITqdQWu89ho2WzWYQ+C4pfIXUPmgd3iOAhrh2hycU gfFOwGTSo0UoY2gAzKCkMwDXQX9pEdJoqEzsxfiQMH/bNnYgn4BGwRuOv88+CLBrPPSt oWXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZbkXzDYE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h25si5696310edv.231.2020.06.24.08.02.31; Wed, 24 Jun 2020 08:02:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZbkXzDYE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404162AbgFXPBy (ORCPT + 99 others); Wed, 24 Jun 2020 11:01:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404142AbgFXPBw (ORCPT ); Wed, 24 Jun 2020 11:01:52 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88F67C0613ED for ; Wed, 24 Jun 2020 08:01:52 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id s10so1559284pgm.0 for ; Wed, 24 Jun 2020 08:01: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=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=dnQ2E2TcxeV64DwguBwfkTCiBovwCwtsBeeXfFZ5YXvwZPxRiC2fDt5yNrms6iAabE 4t9gCPoxIRkWea2PybpsTuzQ2dZEesmsmvptca5OcANz9pjpzPz+cLtzkfbUtIKL2EGM J54PJQrVDDh6+q0+TiXDW/SQEjWsZV8uoH7eXdGF/pMpIPX2wynShfoG60xzTv06mi15 Rul1QJqE44C8S1V2NBQ/l4fcqAZDrnDHuZ2l89r49b/F0I7XPgXJLVNnKYp6rZJd1hAP DGdOXXbhLb/AlFk8Ycbl4SLGOrgoStg9l0nCsYXEkJfb+Qyb0f9e4UR40eEJp7SV/CBw 5mDQ== X-Gm-Message-State: AOAM533tMWQP495V7WGQ/5W6w0O1n1zVDDA8cbpl+bGVHnfgY3lvbBru vcpx7vEou8BqKQp7wBCB5g== 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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