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.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 0978AC433E1 for ; Wed, 19 Aug 2020 12:54:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C97292086A for ; Wed, 19 Aug 2020 12:54:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C97292086A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 600AD8D0019; Wed, 19 Aug 2020 08:54:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 58A6B8D0001; Wed, 19 Aug 2020 08:54:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 479478D0019; Wed, 19 Aug 2020 08:54:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id 2E54A8D0001 for ; Wed, 19 Aug 2020 08:54:29 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E3733362E for ; Wed, 19 Aug 2020 12:54:28 +0000 (UTC) X-FDA: 77167311816.03.pot85_3800dcc27028 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id B82FC28A4E8 for ; Wed, 19 Aug 2020 12:54:28 +0000 (UTC) X-HE-Tag: pot85_3800dcc27028 X-Filterd-Recvd-Size: 3654 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Wed, 19 Aug 2020 12:54:28 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 53506ADC4; Wed, 19 Aug 2020 12:54:53 +0000 (UTC) Date: Wed, 19 Aug 2020 14:54:25 +0200 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Wei Yang , Baoquan He , Pankaj Gupta , Oscar Salvador Subject: Re: [PATCH v1 02/11] mm/memory_hotplug: enforce section granularity when onlining/offlining Message-ID: <20200819125425.GJ5422@dhcp22.suse.cz> References: <20200819101157.12723-1-david@redhat.com> <20200819101157.12723-3-david@redhat.com> <20200819123743.GF5422@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: B82FC28A4E8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: On Wed 19-08-20 14:43:28, David Hildenbrand wrote: > On 19.08.20 14:37, Michal Hocko wrote: > > On Wed 19-08-20 12:11:48, David Hildenbrand wrote: > >> 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 (e.g., we can only mark full sections > >> online/offline via SECTION_IS_ONLINE). > >> > >> Add a simple safety net that to document the restriction now. Current users > >> (core and powernv/memtrace) respect these restrictions. > > > > I do agree with the warning because it clarifies our expectations > > indeed. Se below for more questions. > > > >> Cc: Andrew Morton > >> Cc: Michal Hocko > >> Cc: Wei Yang > >> Cc: Baoquan He > >> Cc: Pankaj Gupta > >> Cc: Oscar Salvador > >> Signed-off-by: David Hildenbrand > >> --- > >> mm/memory_hotplug.c | 10 ++++++++++ > >> 1 file changed, 10 insertions(+) > >> > >> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > >> index c781d386d87f9..6856702af68d9 100644 > >> --- a/mm/memory_hotplug.c > >> +++ b/mm/memory_hotplug.c > >> @@ -801,6 +801,11 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, > >> 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; > > > > This looks looks unnecessarily cryptic to me. Do you want to catch full > > section operation that doesn't start at the usual section boundary? If > > yes the above doesn't work work unless I am missing something. > > > > Why don't you simply WARN_ON_ONCE(nr_pages % PAGES_PER_SECTION). > > !nr_pages doesn't sound like something interesting to care about or why > > do we care? > > > > Also the start pfn has to be section aligned, so we always cover fully > aligned sections (e.g., not two partial ones). OK, I've misread your intention. I thought that we check for the start pfn prior to this warning but we only do that after. Acked-by: Michal Hocko -- Michal Hocko SUSE Labs