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=-7.0 required=3.0 tests=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 80259C2BB1D for ; Tue, 17 Mar 2020 11:01:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 44B3B20714 for ; Tue, 17 Mar 2020 11:01:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44B3B20714 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E8B0A6B0006; Tue, 17 Mar 2020 07:01:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E61DC6B0008; Tue, 17 Mar 2020 07:01:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D77626B000A; Tue, 17 Mar 2020 07:01:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0149.hostedemail.com [216.40.44.149]) by kanga.kvack.org (Postfix) with ESMTP id BF75C6B0006 for ; Tue, 17 Mar 2020 07:01:27 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 1E0175854 for ; Tue, 17 Mar 2020 11:01:26 +0000 (UTC) X-FDA: 76604562972.23.card30_80e28ddace91a X-HE-Tag: card30_80e28ddace91a X-Filterd-Recvd-Size: 6969 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Tue, 17 Mar 2020 11:01:25 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id 25so20938501wmk.3 for ; Tue, 17 Mar 2020 04:01:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6EipgQFVgo/huvY/O4SRrQWe8XDQ0DAlFK59sTbjBUo=; b=dB/ybJVgRKgPuaoJzyEkEfUrKERmWiDoUzW2kQHyj7ou3g6dw8GkKet6vZr8BywMrz NDCG6E07BnfCcwuPNheqPsv5LO3zcPYk60hX6O1JJ6O+NRMGN4Hlvc7jYMOA4sm8fVc3 TndqGppjpZIG3+286cAKificsVfRJzRhYa09GMAMFEU5Dk3rzssrAlK1/202zImsaEWT ImSYV+JdTwPt9WBIqA+NawsCSyOtI1YArEsoexVAacPpKaanFH9rZcugAkteKxuHziz6 rjbb2jUNiNM8jrdzusyS4dyM/s2sWihOKyyatXvDiX20IBoapNVmi9ERItgeH5gJ2kIm S0ww== X-Gm-Message-State: ANhLgQ0Eqivzb4COKfyhZT1k0H484j2PrtorayRm11RGxzH5pT7y4+kE EmkeLBufPYqwL9yRMgLQ+/Y= X-Google-Smtp-Source: ADFU+vsC8Dzy9TGXCGl36ggWufL9wQJFd8vsUJbzPnDHv7C0memWXP80yZxYnWH2b4rw1DPH/xRZdA== X-Received: by 2002:a1c:23d5:: with SMTP id j204mr4961015wmj.59.1584442884527; Tue, 17 Mar 2020 04:01:24 -0700 (PDT) Received: from localhost (ip-37-188-255-121.eurotel.cz. [37.188.255.121]) by smtp.gmail.com with ESMTPSA id k3sm3879311wro.59.2020.03.17.04.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 04:01:23 -0700 (PDT) Date: Tue, 17 Mar 2020 12:01:21 +0100 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-hyperv@vger.kernel.org, Wei Yang , Greg Kroah-Hartman , Andrew Morton , Oscar Salvador , "Rafael J. Wysocki" , Baoquan He Subject: Re: [PATCH v2 8/8] mm/memory_hotplug: allow to specify a default online_type Message-ID: <20200317110121.GN26018@dhcp22.suse.cz> References: <20200317104942.11178-1-david@redhat.com> <20200317104942.11178-9-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200317104942.11178-9-david@redhat.com> 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 Tue 17-03-20 11:49:42, David Hildenbrand wrote: > For now, distributions implement advanced udev rules to essentially > - Don't online any hotplugged memory (s390x) > - Online all memory to ZONE_NORMAL (e.g., most virt environments like > hyperv) > - Online all memory to ZONE_MOVABLE in case the zone imbalance is taken > care of (e.g., bare metal, special virt environments) > > In summary: All memory is usually onlined the same way, however, the > kernel always has to ask user space to come up with the same answer. > E.g., Hyper-V always waits for a memory block to get onlined before > continuing, otherwise it might end up adding memory faster than > hotplugging it, which can result in strange OOM situations. This waiting > slows down adding of a bigger amount of memory. > > Let's allow to specify a default online_type, not just "online" and > "offline". This allows distributions to configure the default online_type > when booting up and be done with it. > > We can now specify "offline", "online", "online_movable" and > "online_kernel" via > - "memhp_default_state=" on the kernel cmdline > - /sys/devices/system/memory/auto_online_blocks > just like we are able to specify for a single memory block via > /sys/devices/system/memory/memoryX/state > > Reviewed-by: Wei Yang > Cc: Greg Kroah-Hartman > Cc: Andrew Morton > Cc: Michal Hocko > Cc: Oscar Salvador > Cc: "Rafael J. Wysocki" > Cc: Baoquan He > Cc: Wei Yang > Signed-off-by: David Hildenbrand As I've said earlier and several times already, I really dislike this interface. But it is fact that this patch doesn't make it any worse. Quite contrary, so feel free to add Acked-by: Michal Hocko > --- > drivers/base/memory.c | 11 +++++------ > include/linux/memory_hotplug.h | 2 ++ > mm/memory_hotplug.c | 8 ++++---- > 3 files changed, 11 insertions(+), 10 deletions(-) > > diff --git a/drivers/base/memory.c b/drivers/base/memory.c > index 8d3e16dab69f..2b09b68b9f78 100644 > --- a/drivers/base/memory.c > +++ b/drivers/base/memory.c > @@ -35,7 +35,7 @@ static const char *const online_type_to_str[] = { > [MMOP_ONLINE_MOVABLE] = "online_movable", > }; > > -static int memhp_online_type_from_str(const char *str) > +int memhp_online_type_from_str(const char *str) > { > int i; > > @@ -394,13 +394,12 @@ static ssize_t auto_online_blocks_store(struct device *dev, > struct device_attribute *attr, > const char *buf, size_t count) > { > - if (sysfs_streq(buf, "online")) > - memhp_default_online_type = MMOP_ONLINE; > - else if (sysfs_streq(buf, "offline")) > - memhp_default_online_type = MMOP_OFFLINE; > - else > + const int online_type = memhp_online_type_from_str(buf); > + > + if (online_type < 0) > return -EINVAL; > > + memhp_default_online_type = online_type; > return count; > } > > diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h > index c6e090b34c4b..ef55115320fb 100644 > --- a/include/linux/memory_hotplug.h > +++ b/include/linux/memory_hotplug.h > @@ -117,6 +117,8 @@ extern int arch_add_memory(int nid, u64 start, u64 size, > struct mhp_restrictions *restrictions); > extern u64 max_mem_size; > > +extern int memhp_online_type_from_str(const char *str); > + > /* Default online_type (MMOP_*) when new memory blocks are added. */ > extern int memhp_default_online_type; > /* If movable_node boot option specified */ > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 1975a2b99a2b..9916977b6ee1 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -74,10 +74,10 @@ int memhp_default_online_type = MMOP_ONLINE; > > static int __init setup_memhp_default_state(char *str) > { > - if (!strcmp(str, "online")) > - memhp_default_online_type = MMOP_ONLINE; > - else if (!strcmp(str, "offline")) > - memhp_default_online_type = MMOP_OFFLINE; > + const int online_type = memhp_online_type_from_str(str); > + > + if (online_type >= 0) > + memhp_default_online_type = online_type; > > return 1; > } > -- > 2.24.1 -- Michal Hocko SUSE Labs