Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp886395ybg; Thu, 19 Mar 2020 10:27:36 -0700 (PDT) X-Google-Smtp-Source: ADFU+vud5bVQbrdKLiRtC7g08whsyIX7SNo2OED16KjTpISbtuOf6rtlPM+iGo/EzgcKB/aoZSjL X-Received: by 2002:a05:6830:120f:: with SMTP id r15mr3167261otp.90.1584638856073; Thu, 19 Mar 2020 10:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584638856; cv=none; d=google.com; s=arc-20160816; b=yyVGi0wxZYzKR4qSUpgeX72xwBKExcMaWW5vBzsRIBU6y5PvVWlqrJAi7dWh+YACrg dgMoamvACml1/igU4k7jJy+Zqm/VBisd444ieH3jDbJK60nB1H7iO/ACEqte2CiYryyQ XBIQUv0HlTlP0+eB6+D7k4apkssz4RVStou9gBBT5s4a8MgYJGin5BmC85qToa9SUc06 1za14i3+tPsqCCwBanbzKbh2DwWar2AhBkWt2+Br8F+yIiWclj694xjRQjGx8E+KdFIj G9EJoV2rG3X8913xXdICQ/b72uzhvmq/JsHVdGEnlmgdpc9dIleQkNfOKhPPCR5tix7r 3F3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=3F6p9VA0cVyFpp1otJBkETuyS8iU0ECrOYMDdRLVRxI=; b=YsLvVpwhx7CuSGEIn3qTuekxM4arr/lpePKYEwygcs7dT2TJ8UizWbwEdPaOWinIP3 nnP7Uek2764k2dk9hIHLwPBtXx6Yec5Wj1oluU2h7nSsSTf/vcUw4F2IMaGcQFdn6w/6 NZ8LY798BuClMl2FUQ7wa+5dSr3s9cXIvfJ9nsS9PmN8x0IgI7ghNEkCqYRZAZCEgr7v sS9bKHiO66vAc+AKpScfuWGhdKWt50GriXvuk3CouYukRHUMPnZ6a0ihiLSc7J7edcaw ehRKw8hHw74MjUruqJHCbUeFl/EmpB4ejMIbNRAqA7n/E2cNtHGa1nh61amDuWYUc4pp kaqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QuAr0rCw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k201si1367399oib.94.2020.03.19.10.27.20; Thu, 19 Mar 2020 10:27:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QuAr0rCw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727471AbgCSR0z (ORCPT + 99 others); Thu, 19 Mar 2020 13:26:55 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37097 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726934AbgCSR0z (ORCPT ); Thu, 19 Mar 2020 13:26:55 -0400 Received: by mail-wr1-f68.google.com with SMTP id w10so4147877wrm.4; Thu, 19 Mar 2020 10:26:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3F6p9VA0cVyFpp1otJBkETuyS8iU0ECrOYMDdRLVRxI=; b=QuAr0rCwgtiF82xHBWqQ4lSffZ977W564JnS7kFkj4jk+O1B4hwEtwYTvDMJd0KPzC W7UMfVthKh74N0igpoKyyZvB59aca9fYgTGHWI0wxqZpebWmfrzwomuaPhyu2VJEO56g p8dYe7vIpKa4hy2K1oGI5SvuFhZUuFjqaQ5nCVNmmA+eKRhwn1dzNTMdTUiPfQVqqylK /qunIobrNuRJE4LBBm/nxChANZ1J+lczwkjXC9am2snUc9QdDh9lM9vvgy4mt1gKjnpW XeCTdXi13mIw6cdMmEAXO9RJzB/RauIdkXZbliOpFv5hr2B7Il01mhJLYeyZ4YNCat++ sZ8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3F6p9VA0cVyFpp1otJBkETuyS8iU0ECrOYMDdRLVRxI=; b=lIfsDiusw09b4ZRQw5u7Be9F5J2jhKUzKMQDrwSBsD4UvFg6M6i5NTRFZewU099JNk 99pP+lDT6lBXMi9IZh7L/Ry5FnUfpGRneAQbPVoGzv2OdR6oqVER2Sx/nMr8FUp+d1JT K02doUFRzxo3h4we8Maw8vldCJ/57XynCyqxuTzCt/9iULyYDokU6ktNy1IsegGP73Dj j3XfoqjPPRb/ermHFu4b5iD4hXz6PmnS6Z2hPXXji4kQqeLOHHj0KYirhsO+sdDB0nIf /m9gX1yyyGDUw16sfbONd4r4iNjFHljGSqNzhpKs6FOOayfH8NlbeJTj0n6dP92zgJaV XyYw== X-Gm-Message-State: ANhLgQ24D7Uv7Whb8lmAE6csKuRIl2CAao6gNBL9h3HDk2WvqlVs8AGT w0w4+2mnAyVPDiUZiahCMxM+xdTIRAPHPVqXbDg= X-Received: by 2002:a5d:56c9:: with SMTP id m9mr5376031wrw.289.1584638812775; Thu, 19 Mar 2020 10:26:52 -0700 (PDT) MIME-Version: 1.0 References: <20200319131221.14044-1-david@redhat.com> <20200319131221.14044-9-david@redhat.com> In-Reply-To: <20200319131221.14044-9-david@redhat.com> From: Pankaj Gupta Date: Thu, 19 Mar 2020 18:26:41 +0100 Message-ID: Subject: Re: [PATCH v3 8/8] mm/memory_hotplug: allow to specify a default online_type 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 , Michal Hocko , Greg Kroah-Hartman , Andrew Morton , Michal Hocko , Oscar Salvador , "Rafael J. Wysocki" , Baoquan He Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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 > onlining 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 > Acked-by: Michal Hocko > 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 > --- > 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 6d6f85bb66e9..93d9ada74ddd 100644 > --- a/include/linux/memory_hotplug.h > +++ b/include/linux/memory_hotplug.h > @@ -118,6 +118,8 @@ extern int arch_add_memory(int nid, u64 start, u64 size, > struct mhp_params *params); > 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 4efcf8cb9ac5..89197163d138 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; > } > -- Acked-by: Pankaj Gupta > 2.24.1 > >