Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp2608383ybg; Fri, 31 Jul 2020 05:22:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyemC+EenK0SrMZaz3uIm91iSPGc25yCHI+NDMeArXG9Ap3ScAZdVh5GKR7DzcwMZ1A4uRe X-Received: by 2002:a50:baea:: with SMTP id x97mr3615527ede.337.1596198141596; Fri, 31 Jul 2020 05:22:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596198141; cv=none; d=google.com; s=arc-20160816; b=GhU3ptimMVoRVkhQs3PT1KlX1FgtTUIwB0bu2bbX4MuzET4XNQeCt5dcCHu7qWGP3y cJrpHmWvp1cTktMQ3kcsq280P0j9mlMLcVR8m5/tIyJMjqywFY5NzFyjaQMyZDat49rQ LjYu5TsDRfF60g+uJAyBplsdg7JOaijWB47KmyCWEJB2/KXFycwqPDxFyQYW7oVJEcMX s7UB3FGdl9Lt7eK9wBcWV7Iz8cpZAremWN26nO+QGbFh+SMQ95oe/+/pb3l9PgjVAtv/ KxVFN43Xi7vW57yyEIDPpH800fiD1+10pQjuEAE+l8qrdJ/WHFuv7+lMyERtLK6xf8I/ 4xPw== 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=C20rXtIxVYuV8kAt9ziq5r9X3XGDWqg/fkrphmJjKRQ=; b=YyYXJVARhgixJNCF1dHVlSvNQx3nk/1vkdW9ntj5YlsY46Q2Q6vRZfebP6ZV6v/zlz Lpo8rwyhz5xjhJ6HioopBT2eb/Q31ZUQJEdQ1AtinV9g6M19phGJ2lfzYupGydzzmzdN bWIxZfBY5IYZkx/8c6mKRgLxIIHC9/3tlwg4QmN1A0rdrgLyDxZ55VO7JDlxIBo+AVJm xziuobduihE+SKpsqUyMf44LwanMKIL3szrir3sQXbj2VkN7wuQ2JSQ7dRGNEZSADEMF pbHexTK/FLWjgxJTE8FJvuPkqy1L3IwM+pbsm8/iQthjhNZF6uszwS9RdEcuamL7yEjm TIHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mL8mwKWQ; 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 h8si2354019ejj.216.2020.07.31.05.21.59; Fri, 31 Jul 2020 05:22:21 -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=mL8mwKWQ; 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 S1733186AbgGaMVh (ORCPT + 99 others); Fri, 31 Jul 2020 08:21:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733152AbgGaMVa (ORCPT ); Fri, 31 Jul 2020 08:21:30 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD2A8C061574 for ; Fri, 31 Jul 2020 05:21:30 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id k1so7201785pjt.5 for ; Fri, 31 Jul 2020 05:21:30 -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=C20rXtIxVYuV8kAt9ziq5r9X3XGDWqg/fkrphmJjKRQ=; b=mL8mwKWQzTvtX66d+UAyvZYdeQfelYFSjj9rVpvye6Z3Z69SI59FpRf6OxSdCEUyh0 1uV7DKEXrssFQAvdcBXZ3OPVVqRYmOyac7+wTTDLdr+Qz6hVv7vV6bwx9Cuyl0x+58ya Yog37R4NlqRmNjaj4HUv7O+CqxVQpBjIrkrNahCOWRl5Bkw+6rLYCG1SSEn4T8gmHLi2 T8tRatkzoVK9YvK4I4N2iskRZEB1mJN4IYFco0Zb6M/bc6/XrJ4TGATj2GeX2HykwvaI f1aIXZJ82amxGxC9ysOXv/8IUR4OArtjUM6WoKZayh72LgryYTd30z7JqrPLZcpm4X1J 5Fjw== 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=C20rXtIxVYuV8kAt9ziq5r9X3XGDWqg/fkrphmJjKRQ=; b=hrRlSMYUCKO2V89oQFNch8VKlIvGkxq4aNDa+DKHLlR9Qvy2YdOFcyhXkBRaEpEv6W XTX7axNE3izpw0wUIQ+ZA0udiQyhzUJTOlu1jEaLDLiArUJC60qXhLmA1Zk0EhsnqmOn ph5V2glv4FaO0/i6XcgZXHdZYkPfLzrOv9uvObX50sL7wujh9XBwse6f7o8P5zjVXOCH Vl7g0ml0y/cza+Myu7B75B3bkj1sNeqr+xvXTyMExWChzrL7NEP3Equ1TZLSaaQAQZ85 XcXYXuDHi9KSfC+rKMXKtDXXlOpJdMo/qwee2TvkkxT+KTJ3WQdrAt2mKgKURiCOyRps 29/w== X-Gm-Message-State: AOAM530GmP3rHHCn+VziJTyjF+AQLvPhpF8grVylLV658yDQ3p8hjmet dBgmcu3pCnIdjuq3v3LDIA== X-Received: by 2002:a63:3d06:: with SMTP id k6mr3577330pga.316.1596198090375; Fri, 31 Jul 2020 05:21:30 -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 m19sm3675692pjv.34.2020.07.31.05.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:29 -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, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 04/16] mm,madvise: Refactor madvise_inject_error Date: Fri, 31 Jul 2020 12:21:00 +0000 Message-Id: <20200731122112.11263-5-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-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: Oscar Salvador Make a proper if-else condition for {hard,soft}-offline. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- mm/madvise.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/madvise.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/madvise.c index 1fe89a5b8d33..2c50c2c5673b 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/madvise.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/madvise.c @@ -886,16 +886,15 @@ static long madvise_remove(struct vm_area_struct *vma, static int madvise_inject_error(int behavior, unsigned long start, unsigned long end) { - struct page *page; struct zone *zone; unsigned long size; if (!capable(CAP_SYS_ADMIN)) return -EPERM; - for (; start < end; start += size) { unsigned long pfn; + struct page *page; int ret; ret = get_user_pages_fast(start, 1, 0, &page); @@ -925,17 +924,14 @@ static int madvise_inject_error(int behavior, if (behavior == MADV_SOFT_OFFLINE) { pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", - pfn, start); - + pfn, start); ret = soft_offline_page(pfn, 0); - if (ret) - return ret; - continue; + } else { + pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", + pfn, start); + ret = memory_failure(pfn, 0); } - pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", - pfn, start); - ret = memory_failure(pfn, 0); if (ret) return ret; } -- 2.17.1