Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp403084imu; Thu, 8 Nov 2018 22:48:34 -0800 (PST) X-Google-Smtp-Source: AJdET5cQxSK/+n/fI5vLkaOywCkTnvOPEGM02dklrDKg4TE2+ZgGUs7sl1sd9J9/f6YcFMc2qSwa X-Received: by 2002:a17:902:598f:: with SMTP id p15-v6mr7638641pli.260.1541746114793; Thu, 08 Nov 2018 22:48:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541746114; cv=none; d=google.com; s=arc-20160816; b=u4gRPkaBEQ63P2YP+muBpU6yRYtOxiTJ5dLJCmPul/2i/EPNVKaArnkemAL8/pGuGP PjstyVY1Bk/9EC7QWkcbSJYytwRZyj5s3Bkf7R685gRebzTnIQsb2Sr8SFVYzf6KDgN5 f2v8MIbDaZ1HNmxcnoI+7ZLeKmBJbCfX65Kd/gZDqsVVypENM90Uz59+NFyaVpqOctWX 6Rhkmk+gi0Km2L3AV99PDsP1Ch9fOD33ustAAzp83XgXB5/Zb5nnhjtwzCcLKlup9nKp oIfM7gItlpzQG5LAw8hBrfyCDrSANuBV0eymrcsCyJFfkFmwT9SA8tO8lj/NLr61nn5S gvmQ== 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=m0e0f9nzNxyxhpTcBsr3tCvUPNiuZ+bV+28ICuX+JQY=; b=gnQ0oPzoGwENwN6PlAAn0E3GFq3XJxHD9qjN9xF4sFXOjYSEx4sY6fvlrAhg33+FRt 48VHO8m9D82e19jhMfhl9FJ3oDZVr6bbQsifmZYoUlw+nuc37gUJsUJjtdd/ge8+KHOu HvE6u5kuEiOMuHJc+BPwdTd3au7ArJsaljY9XkFo0DOIvv8R7fwTL0gS4C2BKDwHZeWl jgeVvSO8tDk69SlA6vSctAFKnq7U4gI27mPYVTev0d4EBwN3BL+EWR3lHWohkJ+NlcoY JHjNXVtZ2YQnAcJFUMr3Ayf13NKfbZ6fP4wbh61M5b/LJRkrdRck/rze6VfjHgyEWaTr Ajxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=f3fUO3sG; 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 m72-v6si6456015pga.114.2018.11.08.22.48.13; Thu, 08 Nov 2018 22:48:34 -0800 (PST) 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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=f3fUO3sG; 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 S1728044AbeKIQ0r (ORCPT + 99 others); Fri, 9 Nov 2018 11:26:47 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45083 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728002AbeKIQ0q (ORCPT ); Fri, 9 Nov 2018 11:26:46 -0500 Received: by mail-pf1-f193.google.com with SMTP id p17-v6so478040pfj.12 for ; Thu, 08 Nov 2018 22:47:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=m0e0f9nzNxyxhpTcBsr3tCvUPNiuZ+bV+28ICuX+JQY=; b=f3fUO3sGOcfSkELF9VhwEATDLBjrZFtcbQKPtLzgiXaaYkML+7ejQCSpk2OalDEGzH lGsQBO43VDXY1NSNNnMO1qYjoh8fvUjH4AxaVhvqn7WvR3CnMtDmZEfFEnRmGcPpgDqC l2E0WUeLgN5ZFbJ8VY0FtBUpgdrOvxiFuiVOlSb+O3z73r9ia4od8Oi1C33rlMuxct/x izmo4xhtAIVtMDAESf57lGJHicM4lMWhwPvIPf6G7cWacr82ehZCx1aoBkBPvz7fyVBW MM1DWevtTcBipdEwBQxYder+tGsTmNtEVTb5ibLZOs4J6Gldrw5EujN9T9ZkOE2iEjmu A4tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=m0e0f9nzNxyxhpTcBsr3tCvUPNiuZ+bV+28ICuX+JQY=; b=gwLWSJCRdJzYVpiWShBwIO3KMiDRVaQXMAPtFgbmG4aypaQYol4hXgafhh9C7B9l14 FvW5cLpr+8GrPGSIGc6mAU9HcZFdPLOA3RDJs7Zc+99M7u9V7iAZF7yW1nZTAnfh1XmC JJQXWC2J6LQvktmnFpEWBm75La7ToIybOjutWxQTJ2fLPostVKmZOWoFRctgOGly98WW 2j0jsLwd2BwkinwoXSa9tvpPT8HHzduq+OHFiEUnR/I8gCDGQWsS3rjRsPChv808o3Bw 3BYGzAH92HnobTgef27JeEDHEv0U5p0Tiq7kNLegQuCjIyu+v0Ytm1gXp6Dw0UmE4/kF 1xTg== X-Gm-Message-State: AGRZ1gIVBHgTMaqBnUDkd/uTs3nH5zKTyuEl4jNvt7QRiYoCOMPAv6Yr psPppsIoBHgWgTQDYJ70v5SZR+tewA== X-Received: by 2002:a63:1b1f:: with SMTP id b31mr6399252pgb.66.1541746057988; Thu, 08 Nov 2018 22:47:37 -0800 (PST) Received: from www9186uo.sakura.ne.jp (www9186uo.sakura.ne.jp. [153.121.56.200]) by smtp.gmail.com with ESMTPSA id c70-v6sm6808355pfg.97.2018.11.08.22.47.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 22:47:37 -0800 (PST) From: Naoya Horiguchi To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Michal Hocko , Andrew Morton , Mike Kravetz , xishi.qiuxishi@alibaba-inc.com, Laurent Dufour Subject: [RFC][PATCH v1 04/11] mm: madvise: call soft_offline_page() without MF_COUNT_INCREASED Date: Fri, 9 Nov 2018 15:47:08 +0900 Message-Id: <1541746035-13408-5-git-send-email-n-horiguchi@ah.jp.nec.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1541746035-13408-1-git-send-email-n-horiguchi@ah.jp.nec.com> References: <1541746035-13408-1-git-send-email-n-horiguchi@ah.jp.nec.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently madvise_inject_error() pins the target page when calling memory error handler, but it's not good because the refcount is just an artifact of error injector and mock nothing about hw error itself. IOW, pinning the error page is part of error handler's task, so let's stop doing it. Signed-off-by: Naoya Horiguchi --- mm/madvise.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git v4.19-mmotm-2018-10-30-16-08/mm/madvise.c v4.19-mmotm-2018-10-30-16-08_patched/mm/madvise.c index 6cb1ca9..9fa0225 100644 --- v4.19-mmotm-2018-10-30-16-08/mm/madvise.c +++ v4.19-mmotm-2018-10-30-16-08_patched/mm/madvise.c @@ -637,6 +637,16 @@ static int madvise_inject_error(int behavior, ret = get_user_pages_fast(start, 1, 0, &page); if (ret != 1) return ret; + /* + * 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); + pfn = page_to_pfn(page); /* @@ -646,16 +656,11 @@ static int madvise_inject_error(int behavior, */ order = compound_order(compound_head(page)); - if (PageHWPoison(page)) { - put_page(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; @@ -663,14 +668,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.7.0