Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp652140ybt; Wed, 24 Jun 2020 08:03:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyF075OyHff3Yky/aMEaz2gLdC8ns+gscrSpyMz17CVAH50QiKLZWA8nFSL4FUrMuK2REZ X-Received: by 2002:a05:6402:148d:: with SMTP id e13mr27894931edv.200.1593010992494; Wed, 24 Jun 2020 08:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593010992; cv=none; d=google.com; s=arc-20160816; b=Xfw8pS/VoW1cZRFMmn1cAnrrAHGl3y0iv2J1YUZWzP7euOKtsDYFLrjY9tm9U7L8X8 rLwxZrF9IShhuYa19Gekig77mVL20GtJRl4rMVfX68FUAzkNztgVtFmU5TwGXswN2Yw7 lw8FXb3rWra2u6nP7aF+q5VF2aVdZBU4ILkMJG9wiAdXzNQO15NKGxG4W4fCJFNyUqGW Vx08A7Vsarbju8hJOgavF2zyci0BULMiWzpmCPJJLJMX7ZlTSt/EiOsLpQlqKLyIbxM0 hCz7Nn5nN5GI10TJRPILnqf+UoEl6OOM5qIxnsEl+tKuyawIOIvJwukGBkJRlIT9/nUv eGqg== 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=8PwurQU1NxfpMHJph1B1p7tgGvKbCO2GLa0tif4yXmY=; b=P8E6b0BnpNbEFfvmhr3juAXcoWoga2yrNu9+lGBNcNBNzV1jW7QP7fknZ+7ssnsW3g PhfDbPZBuX/OFSqGS8WVeON9fYw8IdvsQ6fNSnU+hMigf/h9HNRB57xwRjGn+UwmrYNb EeM1UySZXk6XSqaXI3Uy1mCwvg0Kq3JfjrVpu19YcJdkr8LGuWarIXR1trwS4z4QvyRQ hpePGY5fFFwK5+mboPSGELIArkYLyfy38em+VcR1jYv9csc48xqAUdAWVy2wKjBxBIjz CpT4SCDMqfT6R/D5U7LWYzQIYe2in2sNbJLe0XP9ZuSy0WLHFurERNnE4yNQ4EX/KOWD IpAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OlUun5E3; 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 c15si12804452ejx.148.2020.06.24.08.02.48; Wed, 24 Jun 2020 08:03:12 -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=OlUun5E3; 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 S2404181AbgFXPCB (ORCPT + 99 others); Wed, 24 Jun 2020 11:02:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404165AbgFXPBz (ORCPT ); Wed, 24 Jun 2020 11:01:55 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 305F4C061573 for ; Wed, 24 Jun 2020 08:01:55 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id e8so1547734pgc.5 for ; Wed, 24 Jun 2020 08:01:55 -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=8PwurQU1NxfpMHJph1B1p7tgGvKbCO2GLa0tif4yXmY=; b=OlUun5E3PI4k9fogy7yVJiNq+TrLqHRnF/eCqpsxsTKrWCCHAkjh99qm8Kji4aD2gz KHzGjJmD5OaGQ/wF2rZ0iHiPc4z3oOuPThTrnL54c1Pn16OfcWOlGTv6GgToadt6HEW3 IPPESdDzY/Y8HrXQ55n4wc1scWF08vao/QkxZ8cUtcJNSZ3OGyq01R2sVgtKEGeUZat3 3269OGDWCJOyXGceEmtJd/CQqeu5PhtHTmYMqoke9YDN6yAb/WTsK6KTPkqq2klAY3ci ejtgjnMSjft5/g5uE2QYiHq3Nxd/rsLxKVMBS/tsX4chYx8Ol5YEISRvXV2kKdA4bBzZ S30g== 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=8PwurQU1NxfpMHJph1B1p7tgGvKbCO2GLa0tif4yXmY=; b=RhpSGrY/GrsnxtI71Lgj0h33Y/YeaMa8ZLDn5G15Ba7iIP/K1b73WUMkCHRjRQQ8Bk 3kNeAKwrAiV3T9iSNm6CM+34jocSvkM/32W0Bp6LhPLL375hA+QrMyBkKJI8Qe8Hbl9w hzWTXInUOah0ixlRaCXrs0jUdln0ULpIc9iqbhOWt9/VF4+NTT14DIFeNTAv1bEF7UFm +P5sJwtaKxk9x4nEficGo9jBK8VjvhdbsZiTANbKFW9iTGhcrzT+vjP/e+YpsBR98Z4L XZg+pfoXZjIAQUBXG58kSa6H6AiZ+bWFcmsKEDgrPPL9yaOse9d+OhjFBNe4KgOj6038 HcrQ== X-Gm-Message-State: AOAM5305d/Ny44ZRxtmT1+qxst8GDpRwmVX/4MdlG8rPslK+Vu7rSH8l mN/g4BMa7DYdOGy1JuH42w== X-Received: by 2002:a65:6710:: with SMTP id u16mr16022611pgf.45.1593010914695; Wed, 24 Jun 2020 08:01:54 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:01:54 -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 04/15] mm,madvise: Refactor madvise_inject_error Date: Wed, 24 Jun 2020 15:01:26 +0000 Message-Id: <20200624150137.7052-5-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: 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-rc1-mmots-2020-06-20-21-44/mm/madvise.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/madvise.c index 275b08edd428..bee1f4ac70d6 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 @@ -869,16 +869,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); @@ -908,17 +907,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