From patchwork Tue Oct 2 15:00:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10623815 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60920175A for ; Tue, 2 Oct 2018 15:00:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5411C205A8 for ; Tue, 2 Oct 2018 15:00:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46A35209CC; Tue, 2 Oct 2018 15:00:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD200212D6 for ; Tue, 2 Oct 2018 15:00:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C97536B0006; Tue, 2 Oct 2018 11:00:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C47696B0008; Tue, 2 Oct 2018 11:00:50 -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 B5C226B000A; Tue, 2 Oct 2018 11:00:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by kanga.kvack.org (Postfix) with ESMTP id 5C8916B0006 for ; Tue, 2 Oct 2018 11:00:50 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id 88-v6so1824565wrp.21 for ; Tue, 02 Oct 2018 08:00:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=vV57za+RZegx5K6hatPcdBK9pa1kxQE7f2kJZHzy1nw=; b=qUmiU1p59pDB0Qi6mBQXTBOMHt47KY7a+eJIHosROti9IJSg2VPT+PrnAEmAYjzKUN obeq2ynqPgkq1tFpjqbXpAC0xSEVQnySizNGGQGdGNiu/zu7milXVl4RJbvC9YJYPRl7 jQPulCBvKRchU1MjVqtetN3eqMm2M44BUmCLW1JkQHwJgPVEOOejQQc35pyY4EztF3vp //TiLlY23kmBfQBU2/BWyl7LXdPNq2alhlZFxBEEJ2cskanE4GoB68kK+cF4orAcnpb/ g6c6lEdUzD1XR4/oylJlqpw/XR1uAiFzhUJmYb056kEX3lUOo+xy32e1ZCqloEGJGjkc BLsg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Gm-Message-State: ABuFfoiOBMftzxEmztyoJtHoF+2edwgDrH0pi+feLViuOVXfheaRj5cI XGEPzXmvs+LGZPA5sOVD4nE4GOAUv6RJtKnlXEIgLrYY+QyoC/6j+UJrAhKqvx3SrjeDOLfBk2u j5DKaOxMZP2qLh42yjnaen9u9f8ZO1iN9C8xYFXo/fIonn9tgSqmplVFxdDeIPDJgIW4AwP3Lz0 pbAoL7mFC8TP5M+79ZHASV+oC/ZqNrysveyj6zvZsym+Ses+lf4Mhi8KUKM7+jQYauhNuQ7VKNd OiweM9s8lR5xDMgUWLTsIVdCXfDE7Om2xoyqJ9GjLdgymOBtH+/A0Km2ovHpfs6xDK077Aa3Tjc NPBwtFZgH5NFKKOV+tzcLmYeCLbItWP+AxBmeQJPKDc4PlmJ78Ps+CidErIO7b2ScJLmMy1pMA= = X-Received: by 2002:adf:b456:: with SMTP id v22-v6mr11799755wrd.187.1538492449538; Tue, 02 Oct 2018 08:00:49 -0700 (PDT) X-Received: by 2002:adf:b456:: with SMTP id v22-v6mr11799638wrd.187.1538492447775; Tue, 02 Oct 2018 08:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538492447; cv=none; d=google.com; s=arc-20160816; b=UgrYcHOOX4Bdbcrsho14AcVz/C8BYJa4SH3tq3YkbERdIKf6TU8lgez1WwX7ZNNN8y 5Ac62otUU5+4AvuAUKfFx3+Zr/TYLLzqQhLNzi7BJJZOIFC/aeR08IVkunKwVz5c8How UBzvG9EHXRzYprejB5/ntM//g73CmpouzK1U5aCThx3Udm8OSMLrSD/2wEaIDLj50Zk/ fa53aQLmFN6SLaPqAPtuRUrtWYQfUJvnB6Ij7MHLXNzTjrPGenroB8c83BvyoDwob4on ANKTzfmilU68s1+9qFcvmXUq3okNNdcwiT8EkJV2EK3y+DAgz0HBwoxNXHnv6XeeqEkL q64w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=vV57za+RZegx5K6hatPcdBK9pa1kxQE7f2kJZHzy1nw=; b=D6rxRZ02pO7C6xUAXmFZXJojQ1E/qI3XftVLvCQv65Tr0MIPuLfyazVyi1B3yZfm+T tC5Ktz+CJuStiyzbVQ8spRsLmTGDc/Aecs5BgCfPCaRxS9XNQV9zc98Ca14alAonrCIu w0ZsMrTIfu/Yn+P1FklJUAUzQQS/4AqnxNR1lz5hF4n+RWsEnHjc6Ypep+QWhrEzcb/a deVx2GLz+enIExEOvhmd7WJczqjvHNZ8WpXgR15/n6gUv5c1rBDRnYRfwviuUZVN0NSJ 1KvbGB3q7Y21zG62ooYouZrH80nmCNQ6U8IZNvI7BoELekmZvN7ztWrCpsUwG3DuwaCU lvUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y31-v6sor11369839wrd.50.2018.10.02.08.00.47 for (Google Transport Security); Tue, 02 Oct 2018 08:00:47 -0700 (PDT) Received-SPF: pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Google-Smtp-Source: ACcGV630pDGe5A/pWCB2EVlv2BB5XBijO9pWEn6fBbPzAQbRro5vCpgSrLZoJvlsdk1fPYHop6KN0A== X-Received: by 2002:adf:b188:: with SMTP id q8-v6mr11070301wra.95.1538492447320; Tue, 02 Oct 2018 08:00:47 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id p9-v6sm11325085wmc.37.2018.10.02.08.00.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 08:00:46 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id A2D8F12561E; Tue, 2 Oct 2018 17:00:45 +0200 (CEST) From: Oscar Salvador To: linux-mm@kvack.org Cc: mhocko@suse.com, dan.j.williams@intel.com, yasu.isimatu@gmail.com, rppt@linux.vnet.ibm.com, malat@debian.org, linux-kernel@vger.kernel.org, pavel.tatashin@microsoft.com, jglisse@redhat.com, Jonathan.Cameron@huawei.com, rafael@kernel.org, david@redhat.com, dave.jiang@intel.com, Oscar Salvador Subject: [RFC PATCH v3 0/5] Do not touch pages/zones during hot-remove path Date: Tue, 2 Oct 2018 17:00:24 +0200 Message-Id: <20181002150029.23461-1-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 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: X-Virus-Scanned: ClamAV using ClamSMTP I was about to send the patchset without RFC as suggested, but I wanted to give it one more spin before sending it officially. I rebased this patchset on top of [1] and [2]. I chose to rebase this on top of [1] because after that, HMM/devm got some of their code unified, and the changes to be done were less. Currently, the operations layout performed by the hot-add/remove and offline/online stages looks like the following: - hot-add memory: a) Allocate a new resouce based on the hot-added memory b) Add memory sections for the hot-added memory - online memory: c) Re-adjust zone/pgdat nr of pages (managed, spanned, present) d) Initialize the pages from the new memory-range e) Online memory sections - offline memory: f) Offline memory sections g) Re-adjust zone/pgdat nr of managed/present pages - hot-remove memory: i) Re-adjust zone/pgdat nr of spanned pages j) Remove memory sections k) Release resource This is not right for two reasons: 1) If we do not get to online memory added by a hot-add operation, and we offline it right away, we can access steal pages as these are only initialized during the onlining stage. Two problems have been reported for this [3] and [4] 2) hot-add/remove memory operations should only care about sections and memblock, nothing else. This patchset moves the handling of the zones/pages from the hot-remove path to the offline stage. One of the things that made me scratch my head is the handling of the memory-hotplug in regard of HMM/devm. I really scratched my head to find out a way to handle it properly and nicely, but let me be honest about this, my knowledge of that part of the code tends to 0. Jerome reviewed that part of the changes and it looked ok for him, and Pavel did not see anything wrong in v2 either. But I would like to get more feedback before sending it without RFC. The picture we have after this is: - hot-add memory: a) Allocate a new resouce based on the hot-added memory b) Add memory sections for the hot-added memory - online memory: c) Re-adjust zone/pgdat nr of pages (managed, spanned, present) d) Initialize the pages from the new memory-range e) Online memory sections - offline memory: f) Offline memory sections g) Re-adjust zone/pgdat nr of managed/present/spanned pages - hot-remove memory: i) Remove memory sections j) Release resource [1] https://patchwork.kernel.org/cover/10613425/ [2] https://patchwork.kernel.org/cover/10617699/ [3] https://patchwork.kernel.org/patch/10547445/ [4] https://www.spinics.net/lists/linux-mm/msg161316.html Oscar Salvador (5): mm/memory_hotplug: Add nid parameter to arch_remove_memory mm/memory_hotplug: Create add/del_device_memory functions mm/memory_hotplug: Check for IORESOURCE_SYSRAM in release_mem_region_adjustable mm/memory_hotplug: Move zone/pages handling to offline stage mm/memory-hotplug: Rework unregister_mem_sect_under_nodes arch/ia64/mm/init.c | 6 +- arch/powerpc/mm/mem.c | 13 +--- arch/s390/mm/init.c | 2 +- arch/sh/mm/init.c | 6 +- arch/x86/mm/init_32.c | 6 +- arch/x86/mm/init_64.c | 10 +-- drivers/base/memory.c | 9 ++- drivers/base/node.c | 38 ++-------- include/linux/memory.h | 2 +- include/linux/memory_hotplug.h | 17 +++-- include/linux/node.h | 7 +- kernel/memremap.c | 50 +++++--------- kernel/resource.c | 15 ++++ mm/memory_hotplug.c | 153 ++++++++++++++++++++++++++--------------- mm/sparse.c | 4 +- 15 files changed, 169 insertions(+), 169 deletions(-)