From patchwork Fri Oct 16 02:44:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11840625 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C957514B4 for ; Fri, 16 Oct 2020 02:44:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7D03C20878 for ; Fri, 16 Oct 2020 02:44:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="z/JV5ykU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D03C20878 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 935F6940021; Thu, 15 Oct 2020 22:44:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8E6B5940007; Thu, 15 Oct 2020 22:44:44 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82412940021; Thu, 15 Oct 2020 22:44:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id 52392940007 for ; Thu, 15 Oct 2020 22:44:44 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E26018249980 for ; Fri, 16 Oct 2020 02:44:43 +0000 (UTC) X-FDA: 77376245646.22.box46_0b11d5527219 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id B2BAA18038E60 for ; Fri, 16 Oct 2020 02:44:42 +0000 (UTC) X-Spam-Summary: 1,0,0,1c674ca7dbdd9260,d41d8cd98f00b204,akpm@linux-foundation.org,,RULES_HIT:41:355:379:800:960:967:973:988:989:1260:1345:1359:1381:1431:1437:1534:1542:1711:1730:1747:1777:1792:2194:2199:2393:2525:2559:2563:2682:2685:2736:2741:2859:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3865:3867:3868:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4043:4321:5007:6119:6261:6653:6737:7514:7576:7903:9025:9545:10004:11026:11473:11658:11914:12043:12048:12296:12297:12517:12519:12555:12679:12986:13161:13229:13255:13846:14096:14181:14721:21080:21451:21627:21939:21990:30054:30064,0,RBL:198.145.29.99:@linux-foundation.org:.lbl8.mailshell.net-62.2.0.100 64.100.201.201;04yg1bqb16ff3yuufz7xe9mypcb4bypyemx5c8gjuyohqodaxwb8aekumqncpii.1itnosokr4zff9pbgirjm9h1nswauhfoba8kiazoe4mptzt4f7zzbq8rzqfen4f.w-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Cus tom_rule X-HE-Tag: box46_0b11d5527219 X-Filterd-Recvd-Size: 3964 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Fri, 16 Oct 2020 02:44:42 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 75EB62087D; Fri, 16 Oct 2020 02:44:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602816281; bh=HBgidZIBSKhm02N61qN8wLnnIq23T+fV1TubSu9maqs=; h=Date:From:To:Subject:In-Reply-To:From; b=z/JV5ykUCPOcT2kMnxZ588e1mDylBs/JZ1XVfc+wHTENUeEfVAedyaS+Vnf16owg2 SuK2td9+TyJbEnuV130KC7UzCxi/mxWr90sHzV7wYI9VKKEjaxXyVLQXt9mCCjkvme DNiTnVKIju6Lw1Gb4+FMne3bpmZA3k29iUhGyaYc= Date: Thu, 15 Oct 2020 19:44:40 -0700 From: Andrew Morton To: akpm@linux-foundation.org, bhe@redhat.com, charante@codeaurora.org, dan.j.williams@intel.com, david@redhat.com, fenghua.yu@intel.com, linux-mm@kvack.org, logang@deltatee.com, mgorman@suse.de, mgorman@techsingularity.net, mhocko@suse.com, mm-commits@vger.kernel.org, osalvador@suse.de, pankaj.gupta.linux@gmail.com, richard.weiyang@linux.alibaba.com, rppt@kernel.org, tony.luck@intel.com, torvalds@linux-foundation.org, walken@google.com, willy@infradead.org Subject: [patch 060/156] mm/memory_hotplug: enforce section granularity when onlining/offlining Message-ID: <20201016024440.h6U4hLFGZ%akpm@linux-foundation.org> In-Reply-To: <20201015192732.f448da14e9854c7cb7299956@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: David Hildenbrand Subject: mm/memory_hotplug: enforce section granularity when onlining/offlining Already two people (including me) tried to offline subsections, because the function looks like it can deal with it. But we really can only online/offline full sections that are properly aligned (e.g., we can only mark full sections online/offline via SECTION_IS_ONLINE). Add a simple safety net to document the restriction now. Current users (core and powernv/memtrace) respect these restrictions. Link: https://lkml.kernel.org/r/20200819175957.28465-3-david@redhat.com Signed-off-by: David Hildenbrand Acked-by: Michal Hocko Reviewed-by: Oscar Salvador Cc: Wei Yang Cc: Baoquan He Cc: Pankaj Gupta Cc: Charan Teja Reddy Cc: Dan Williams Cc: Fenghua Yu Cc: Logan Gunthorpe Cc: "Matthew Wilcox (Oracle)" Cc: Mel Gorman Cc: Mel Gorman Cc: Michel Lespinasse Cc: Mike Rapoport Cc: Tony Luck Signed-off-by: Andrew Morton --- mm/memory_hotplug.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/mm/memory_hotplug.c~mm-memory_hotplug-enforce-section-granularity-when-onlining-offlining +++ a/mm/memory_hotplug.c @@ -809,6 +809,11 @@ int __ref online_pages(unsigned long pfn int ret; struct memory_notify arg; + /* We can only online full sections (e.g., SECTION_IS_ONLINE) */ + if (WARN_ON_ONCE(!nr_pages || + !IS_ALIGNED(pfn | nr_pages, PAGES_PER_SECTION))) + return -EINVAL; + mem_hotplug_begin(); /* associate pfn range with the zone */ @@ -1494,6 +1499,11 @@ int __ref offline_pages(unsigned long st struct memory_notify arg; char *reason; + /* We can only offline full sections (e.g., SECTION_IS_ONLINE) */ + if (WARN_ON_ONCE(!nr_pages || + !IS_ALIGNED(start_pfn | nr_pages, PAGES_PER_SECTION))) + return -EINVAL; + mem_hotplug_begin(); /*