Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp928702ybg; Fri, 18 Oct 2019 09:23:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnLQZT9TSyX9vmlQRtZiidTMm8fYH9Vdql6FkQ+hXxsQGBPUrXhgnOSXdqn/JU5ZwQY2Ub X-Received: by 2002:a17:906:cc90:: with SMTP id oq16mr9309195ejb.322.1571415828841; Fri, 18 Oct 2019 09:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571415828; cv=none; d=google.com; s=arc-20160816; b=D87kPTN+77Ma/rvI7zeWhZQu3Ru5TdorHhGs7HxzSkPHLvSXNMhzoJZj/cTrPppiWP 1kxARE33fAgWx7K5NnW3YOgqUUt1MNc4sRqdGAMs+onsEHLQXgaeoR78GszWfU+Vv7wR q24mei+x3MIagCh8jzPxZShDtTSXzJ4VpBqfqAhjAUkhkYKdsAu+ZqYjPUOej5J1jNwZ 3xfvpIXHA7nHf/BEjVkOYQr0bICfKKkAIVZOOWl4+DMmleRnKL/p3Kjn9QEOOq/cw5Ck M+k0rZts9WG26XKLiDcMwxI1v58lsfD4urtdin8tVULBXdcIxSsBMv7xBnd/r9uxJwyf 1lZg== 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; bh=yy/U60fjpmgK/wkIVU2uMX7XAqDz7ilL81GQRT5Sfaw=; b=mT3EM/XbXNHcOmmElTCYRTqOlM16X7KzX4sPmCFoyzBc7De7kfbYxL9R1QKdSCKxX5 dXa17ETkDOB2puZMBPUDFLSqg9XwLOLi/UVsu7LZuhrLhPIescl2/RHW0bKlpCFMevnO xs4+BFg066ZhbHxW4Z49oss0ZxEIU+36pUD6SbxXD2KypxzmjYHjnRSqcIFsWG/u5uA8 lMhYuTLjSS/2Z+SyVUNEetTeTqS8mLUZfj6p5gk39keWhZaWj+JpFBMD5EzwDZ5Rv3JD RSDdCNGxOcugi4qadaPuJ/aBYKlCXgzPHhJRbHBOuAj6zy7hKVUpuORmmnp6JrDKkOJZ /Vag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si3488999ejp.287.2019.10.18.09.23.24; Fri, 18 Oct 2019 09:23:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440116AbfJQOVe (ORCPT + 99 others); Thu, 17 Oct 2019 10:21:34 -0400 Received: from mx2.suse.de ([195.135.220.15]:40530 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2440096AbfJQOVe (ORCPT ); Thu, 17 Oct 2019 10:21:34 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A74EBB488; Thu, 17 Oct 2019 14:21:32 +0000 (UTC) From: Oscar Salvador To: n-horiguchi@ah.jp.nec.com Cc: mhocko@kernel.org, mike.kravetz@oracle.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [RFC PATCH v2 02/16] mm,madvise: call soft_offline_page() without MF_COUNT_INCREASED Date: Thu, 17 Oct 2019 16:21:09 +0200 Message-Id: <20191017142123.24245-3-osalvador@suse.de> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20191017142123.24245-1-osalvador@suse.de> References: <20191017142123.24245-1-osalvador@suse.de> 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 Signed-off-by: Naoya Horiguchi Signed-off-by: Oscar Salvador --- mm/madvise.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index 2be9f3fdb05e..89ed9a22ff4f 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -878,16 +878,24 @@ static int madvise_inject_error(int behavior, */ order = compound_order(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(page, MF_COUNT_INCREASED); + ret = soft_offline_page(page, 0); if (ret) return ret; continue; @@ -895,14 +903,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.12.3