From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BB9BC2BA2B for ; Wed, 15 Apr 2020 06:40:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6546E206F9 for ; Wed, 15 Apr 2020 06:40:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2634938AbgDOGkf (ORCPT ); Wed, 15 Apr 2020 02:40:35 -0400 Received: from foss.arm.com ([217.140.110.172]:38190 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2634919AbgDOGkb (ORCPT ); Wed, 15 Apr 2020 02:40:31 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1FC971042; Tue, 14 Apr 2020 23:40:31 -0700 (PDT) Received: from p8cg001049571a15.arm.com (unknown [10.163.1.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 14A233F73D; Tue, 14 Apr 2020 23:44:37 -0700 (PDT) From: Anshuman Khandual To: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, catalin.marinas@arm.com, will@kernel.com, mark.rutland@arm.com, Anshuman Khandual , Steve Capper , David Hildenbrand , Yu Zhao , Hsin-Yi Wang , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] arm64/hotplug: Process MEM_OFFLINE and MEM_CANCEL_OFFLINE Date: Wed, 15 Apr 2020 12:09:44 +0530 Message-Id: <1586932784-16315-3-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586932784-16315-1-git-send-email-anshuman.khandual@arm.com> References: <1586932784-16315-1-git-send-email-anshuman.khandual@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Process MEM_OFFLINE and MEM_CANCEL_OFFLINE memory events to intercept any possible error conditions during memory offline operation. This includes if boot memory still got offlined even after an expilicit notifier failure or if non-boot memory got declined for an offline request. This help improve memory notifier robustness while also enhancing debug capabilities during various potential memory offlining error conditions. Cc: Catalin Marinas Cc: Will Deacon Cc: Andrew Morton Cc: Mark Rutland Cc: Steve Capper Cc: David Hildenbrand Cc: Yu Zhao Cc: Hsin-Yi Wang Cc: Thomas Gleixner Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/arm64/mm/mmu.c | 52 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index a374e4f51a62..48c71d8a29b2 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1422,13 +1422,55 @@ static int prevent_bootmem_remove_notifier(struct notifier_block *nb, unsigned long end_pfn = arg->start_pfn + arg->nr_pages; unsigned long pfn = arg->start_pfn; - if (action != MEM_GOING_OFFLINE) + if ((action != MEM_GOING_OFFLINE) && (action != MEM_OFFLINE) && + (action != MEM_CANCEL_OFFLINE)) return NOTIFY_OK; - for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) { - ms = __pfn_to_section(pfn); - if (early_section(ms)) - return NOTIFY_BAD; + if (action == MEM_GOING_OFFLINE) { + for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) { + ms = __pfn_to_section(pfn); + if (early_section(ms)) { + pr_warn("Boot memory offlining attempted\n"); + return NOTIFY_BAD; + } + } + } else if (action == MEM_OFFLINE) { + for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) { + ms = __pfn_to_section(pfn); + if (early_section(ms)) { + + /* + * This should have never happened. Boot memory + * offlining should have been prevented by this + * very notifier. Probably some memory removal + * procedure might have changed which would then + * require further debug. + */ + pr_err("Boot memory offlined\n"); + return NOTIFY_BAD; + } + } + } else if (action == MEM_CANCEL_OFFLINE) { + enum offline_failure_reason reason = *(int *)arg->data; + + if (reason != OFFLINE_FAILURE_NOTIFIER) + return NOTIFY_OK; + + for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) { + ms = __pfn_to_section(pfn); + if (early_section(ms)) + return NOTIFY_OK; + } + + /* + * This should have never happened. Non boot memory + * offlining should never have been prevented from + * this notifier. Probably some memory hot removal + * procedure might have changed which would then + * require further debug. + */ + pr_err("Notifier declined non boot memory offlining\n"); + return NOTIFY_BAD; } return NOTIFY_OK; } -- 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78E32C3815B for ; Wed, 15 Apr 2020 06:40:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1914C20CC7 for ; Wed, 15 Apr 2020 06:40:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QLC9j+y4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1914C20CC7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=LrqB2QNmsT7Y3hIdlQddmym8j2napAEtleOTC06dtYk=; b=QLC9j+y4QLIBHve8bH3XRtBc78 bdPw40EtzHTRyug1vqjyevwKcYE/GX6J05DWznMazSD2FAHuxtUwcNfXwH0qFsRHHAHLD4UT7cvoW nifduOMbnFnpHau8zw9Hx3zNbXiX6iHQrsUIAwfSODbaFtZXxfzgn8f8W+FGJ6ZLcKDd3Mxk8XRHm R+nvUQZTO0zwSkU+Ss7hU7cFez6MpplNC/94X5QAU/9Dut+wGIZ01BxteYf7S3Xm40RSM5lOdBe5N qiqa3hRHYXODaAM/4t+HvkNnd4dM0vGwRVaLtvccgWgAnL4xgzK/oMEEhNqpNXIJT4Rc2ZkEkLaMf q81S7RkQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jObjC-0000eA-4U; Wed, 15 Apr 2020 06:40:54 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jObiq-0000R2-Ll for linux-arm-kernel@lists.infradead.org; Wed, 15 Apr 2020 06:40:37 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1FC971042; Tue, 14 Apr 2020 23:40:31 -0700 (PDT) Received: from p8cg001049571a15.arm.com (unknown [10.163.1.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 14A233F73D; Tue, 14 Apr 2020 23:44:37 -0700 (PDT) From: Anshuman Khandual To: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] arm64/hotplug: Process MEM_OFFLINE and MEM_CANCEL_OFFLINE Date: Wed, 15 Apr 2020 12:09:44 +0530 Message-Id: <1586932784-16315-3-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586932784-16315-1-git-send-email-anshuman.khandual@arm.com> References: <1586932784-16315-1-git-send-email-anshuman.khandual@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200414_234032_829000_ED87D5CB X-CRM114-Status: GOOD ( 14.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, will@kernel.com, Steve Capper , catalin.marinas@arm.com, Anshuman Khandual , David Hildenbrand , linux-kernel@vger.kernel.org, Hsin-Yi Wang , akpm@linux-foundation.org, Thomas Gleixner , Yu Zhao MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Process MEM_OFFLINE and MEM_CANCEL_OFFLINE memory events to intercept any possible error conditions during memory offline operation. This includes if boot memory still got offlined even after an expilicit notifier failure or if non-boot memory got declined for an offline request. This help improve memory notifier robustness while also enhancing debug capabilities during various potential memory offlining error conditions. Cc: Catalin Marinas Cc: Will Deacon Cc: Andrew Morton Cc: Mark Rutland Cc: Steve Capper Cc: David Hildenbrand Cc: Yu Zhao Cc: Hsin-Yi Wang Cc: Thomas Gleixner Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/arm64/mm/mmu.c | 52 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index a374e4f51a62..48c71d8a29b2 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1422,13 +1422,55 @@ static int prevent_bootmem_remove_notifier(struct notifier_block *nb, unsigned long end_pfn = arg->start_pfn + arg->nr_pages; unsigned long pfn = arg->start_pfn; - if (action != MEM_GOING_OFFLINE) + if ((action != MEM_GOING_OFFLINE) && (action != MEM_OFFLINE) && + (action != MEM_CANCEL_OFFLINE)) return NOTIFY_OK; - for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) { - ms = __pfn_to_section(pfn); - if (early_section(ms)) - return NOTIFY_BAD; + if (action == MEM_GOING_OFFLINE) { + for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) { + ms = __pfn_to_section(pfn); + if (early_section(ms)) { + pr_warn("Boot memory offlining attempted\n"); + return NOTIFY_BAD; + } + } + } else if (action == MEM_OFFLINE) { + for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) { + ms = __pfn_to_section(pfn); + if (early_section(ms)) { + + /* + * This should have never happened. Boot memory + * offlining should have been prevented by this + * very notifier. Probably some memory removal + * procedure might have changed which would then + * require further debug. + */ + pr_err("Boot memory offlined\n"); + return NOTIFY_BAD; + } + } + } else if (action == MEM_CANCEL_OFFLINE) { + enum offline_failure_reason reason = *(int *)arg->data; + + if (reason != OFFLINE_FAILURE_NOTIFIER) + return NOTIFY_OK; + + for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) { + ms = __pfn_to_section(pfn); + if (early_section(ms)) + return NOTIFY_OK; + } + + /* + * This should have never happened. Non boot memory + * offlining should never have been prevented from + * this notifier. Probably some memory hot removal + * procedure might have changed which would then + * require further debug. + */ + pr_err("Notifier declined non boot memory offlining\n"); + return NOTIFY_BAD; } return NOTIFY_OK; } -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel