Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp614663ybz; Wed, 15 Apr 2020 15:10:52 -0700 (PDT) X-Google-Smtp-Source: APiQypJDCHYAu/taIRVpoKbXnqrsIYa3txjzZPM+3iSx5KyT719gFyVHF94Yl9yMnoG2P5b+T4eO X-Received: by 2002:a17:906:412:: with SMTP id d18mr6628917eja.54.1586988652569; Wed, 15 Apr 2020 15:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586988652; cv=none; d=google.com; s=arc-20160816; b=qcir23UK6HPrmJZPX2wWOSP9OsW5Av8ciUjwWbCF1zR3Jbu/i07T1uHjXi7h6huh69 KNi/tamDf9mncCt5bsh1LR0vEnYx4ByT1D2wID8uo7EeQI/99jdY1neH6BQ2ybxxvevh WabHdBL/tVdJEh3CVd6p01LQZsqnHc0ne/i5tbhQFcgMbgi3xgTm33ep0Unlfqb38BEN 5nssGpOOQwvMugrDn8SCG/8xcyEaPYWrlbW6L+PihWB8y179QOg3P46dhj2gJO/BZLB+ fil7V14WRpoCJJZ85hh1QDbu/C6TeJi3O2ru3xSi2s1grVRmerpgod14FQ6CzCl2PXtA nszA== 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=k5DfDB5eEPBIwCO4mecvTBHhz3gBq27GBH7JrS0K/jQ=; b=FKag5zWy6QGH7OyswnCd+b/NRBhTGA1ib5Qf5yz2VrA4jlfNFp887fSv5lAAzJ7Ybl fJAWCQVb6wBsZna7ztetxpkqvPFhlVdGypNEMpT2zZhkJVINplbH/ta9m83QOYX8vFU5 JBtRXSYCovfidMlQ/pFcDi81m+1IORhV3+V8KvHB2+jSSZSrWCiw49Nay+vqHKy+99jn 4zz1Bp/qJXbYmAo8N3Lno1BNiHPQk1xb2sMYqUonL6S5Y7qGwq8bneYvEYb7D6pIJTEa SiNaEN7QCL5cDnNP9ToNo6KX3TV/5aIg08K/V6jsqoFZLz8QoI7O/cGxv7/hgS6G1wI2 hCWA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si11209126ejj.33.2020.04.15.15.10.29; Wed, 15 Apr 2020 15:10:52 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2634934AbgDOGke (ORCPT + 99 others); Wed, 15 Apr 2020 02:40:34 -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