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.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 2E936C433E3 for ; Wed, 19 Aug 2020 10:12:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E8069206B5 for ; Wed, 19 Aug 2020 10:12:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aZTwzL1x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8069206B5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 26DFA8D0005; Wed, 19 Aug 2020 06:12:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CFB48D000E; Wed, 19 Aug 2020 06:12:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 070A98D0005; Wed, 19 Aug 2020 06:12:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0211.hostedemail.com [216.40.44.211]) by kanga.kvack.org (Postfix) with ESMTP id DBDF78D000E for ; Wed, 19 Aug 2020 06:12:15 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9DC078248047 for ; Wed, 19 Aug 2020 10:12:15 +0000 (UTC) X-FDA: 77166903030.29.rest99_1f0d73227027 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 69FF618086CC2 for ; Wed, 19 Aug 2020 10:12:15 +0000 (UTC) X-HE-Tag: rest99_1f0d73227027 X-Filterd-Recvd-Size: 3978 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Wed, 19 Aug 2020 10:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597831934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vlCKAT62+8+U0+wxP9CvYzTk2kxwxQCQMREWprhcu2g=; b=aZTwzL1xxCqpZhA+gJvesShnE6kcc+LjF5jg5zUHPEs/vcm+tduq3HDPziz85sYLCiJPYq nFoWHePCJ+XYH3gJ2enSMfN9X80NAA4Wf6yNH4eJ8BYtGoBqwvwRoU4QslUSRXyyt7mNOk MI4NxQLv+X1NwQxg65PBAIY0n69rtB4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-305-iCd5QS9IOBSLJycLNxIPiQ-1; Wed, 19 Aug 2020 06:12:12 -0400 X-MC-Unique: iCd5QS9IOBSLJycLNxIPiQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7CC1B186A563; Wed, 19 Aug 2020 10:12:10 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-11.ams2.redhat.com [10.36.114.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F5DA16597; Wed, 19 Aug 2020 10:12:08 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Michal Hocko , Wei Yang , Baoquan He , Pankaj Gupta , Oscar Salvador Subject: [PATCH v1 02/11] mm/memory_hotplug: enforce section granularity when onlining/offlining Date: Wed, 19 Aug 2020 12:11:48 +0200 Message-Id: <20200819101157.12723-3-david@redhat.com> In-Reply-To: <20200819101157.12723-1-david@redhat.com> References: <20200819101157.12723-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Rspamd-Queue-Id: 69FF618086CC2 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 Content-Transfer-Encoding: quoted-printable 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: 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 use= rs (core and powernv/memtrace) respect these restrictions. 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 l= ong nr_pages, int ret; struct memory_notify arg; =20 + /* 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(); =20 /* associate pfn range with the zone */ @@ -1483,6 +1488,11 @@ int __ref offline_pages(unsigned long start_pfn, u= nsigned long nr_pages) struct memory_notify arg; char *reason; =20 + /* 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(); =20 /* --=20 2.26.2