From patchwork Mon Oct 15 15:30:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10642049 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 C0AEE925 for ; Mon, 15 Oct 2018 15:30:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA80E29AF4 for ; Mon, 15 Oct 2018 15:30:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BD2229B16; Mon, 15 Oct 2018 15:30:57 +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 1884729AF4 for ; Mon, 15 Oct 2018 15:30:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9135C6B0005; Mon, 15 Oct 2018 11:30:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8C1DA6B0006; Mon, 15 Oct 2018 11:30:55 -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 7B13E6B000A; Mon, 15 Oct 2018 11:30:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by kanga.kvack.org (Postfix) with ESMTP id 2063E6B0005 for ; Mon, 15 Oct 2018 11:30:55 -0400 (EDT) Received: by mail-wm1-f72.google.com with SMTP id y203-v6so14565651wmg.9 for ; Mon, 15 Oct 2018 08:30:55 -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=LU4r8F9ALUwSKM0hFeYt7FRRV25cfLCEn+tw+FqJXU0=; b=BE80j9Hgbbf2w3obzCjJnhnuCbaXXfayH50kxveOt/HeWUl0usXGK+BTC8mN+Lt9wj MnKZzK2TA5o9ADYPEYWyknTewVMNIDErIsVyMqewJ1WkNU/N0p2skgPT22D2TOB/ULrR qKeSoC/esTHbuPmL16hu2kMk3Sp90Qrkcj7HUbqIoflTsa44UaTjVfsExkxnjCNqngHT fgc9BJBxPeDujpVwklrblQy5NBXT0QgIwnG9v85Nd+E/cC3gEkldQge8YMZmPfq4jqmS eVgi7EQIN6fbBz/JmnUkvV5RdDGcjJBR/TtufgWn8mPK5lRFf6VLA0kOj2Asp/SEgyri QohA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Gm-Message-State: ABuFfogIA2giYzSBA0mWSEuK7uZCE/8GbsGGAbYi3bkO2wG9A72G34V4 YogxkdFi5GnvqsNdOwr4i75ePf0z1iTAy+432yRjUKdM63aP5E27UaEICFqiYULhlckAT1WZVKr QfblXJzEwKF8M+Tz3SbFAxbPq9rRQXvSXsixdcA1UpG+i2lgAAEBnAfb1fPAnkIn7YZbeD2YHYR yEZYpVha9PiEcctEmMdOLhqibXfaeh3Xh1oQw+tAyLGsdBlU1lNyEA0RAq49f+Y+TROEsiMUhl+ M0OVyqt+eKPsgcmTy5o8bVa1lzW7wB8//V3dKcHlNzkdBXMCcaLSMVgAWKsKsDJcR/MWn7CoTeY 9U0kOut3SdYQ5SjhnVTFf/KJWZggxGFWs11TSvFikJdEPxGaOB2zrRwgqjL3GnmtKcipz2o8Sg= = X-Received: by 2002:adf:fb4b:: with SMTP id c11-v6mr14542547wrs.117.1539617454561; Mon, 15 Oct 2018 08:30:54 -0700 (PDT) X-Received: by 2002:adf:fb4b:: with SMTP id c11-v6mr14542484wrs.117.1539617453530; Mon, 15 Oct 2018 08:30:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539617453; cv=none; d=google.com; s=arc-20160816; b=QGdcfsJLqE3XFdpHzdwhUlMf3TPORl0GyLpk7rN0zxvG9gYuVn6jLMZ5Sn5d4SbHAP o9pZK91c82m0D7JOLdODVCZxMwSdutVMELevoKc2cFxgNAs9nkCnkns7RWjAtk6+F+lP Sns8TFwLi4/0EIxzM8W1AOs87KnL29yCWqYOqXir1boq5rRAbSFsiv++dtvcbMm0luJq U94PW7YVHQXfXqisAynxZsKgNnAUPbGj5I+SkBrmFrTpjqR2Kim7I/bL4r1CtGdur8hT AIVsvRXvr1mfLgTac1Nb2NNJx04yvMI9udQ97/VqmeWrIqnQr1i/pYXF631AAIrjhI5J nsyA== 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=LU4r8F9ALUwSKM0hFeYt7FRRV25cfLCEn+tw+FqJXU0=; b=cbHT4TfZzznSYS0f9K4RRBwd3yUTd/N92LRuNSfyu7ksm0xow0o8XAYYm6rBCcvu5t rV3jvvRgQ7InIhIENkaqPxFJrPRT20K4fOjZ8sf2kyCfYUHgMTYOqPklDD3sCExoo7lS nKDOck5bgdP63EYg7ccx1vnXjDpnyCHLwCA90YY+JFBZTL6/SAA2zEpE4ZNgepm27cXm pywOtuuKNhWO0glRmFBE9/WySG5HC4jhFHKT36g3ttEFmDsZTsXxm5790THADRLqfG71 evtTspg1KT0hZqTOo80XNhOhRSSJX7fDSz+qJUF1Syclhd2ZdF3BTZSt7Q3ifBRvAXVm wPkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id l23-v6sor5704589wmc.6.2018.10.15.08.30.53 for (Google Transport Security); Mon, 15 Oct 2018 08:30:53 -0700 (PDT) Received-SPF: pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Google-Smtp-Source: ACcGV60ElEusojk80rAhPz/fnJhPg3FeIAW4+zGJf9j3lTeckJXR8OKcY7YK8QbGrLRmF29+k/5DLg== X-Received: by 2002:a7b:c00a:: with SMTP id c10-v6mr13207541wmb.73.1539617452849; Mon, 15 Oct 2018 08:30:52 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id k7-v6sm10931764wmf.22.2018.10.15.08.30.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 08:30:52 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 398DF1251F0; Mon, 15 Oct 2018 17:30:51 +0200 (CEST) From: Oscar Salvador To: akpm@linux-foundation.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, linux-mm@kvack.org, alexander.h.duyck@linux.intel.com, Oscar Salvador Subject: [PATCH 0/5] Do not touch pages/zones during hot-remove path Date: Mon, 15 Oct 2018 17:30:29 +0200 Message-Id: <20181015153034.32203-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 From: Oscar Salvador This patchset aims to solve [1] and [2] issues. Due to the lack of feedback of previous versions, I decided to go safe, so I reverted some of the changes I did in RFCv3: 1) It is no longer based on [3], although the code would be easier and the changes less. 2) hotplug lock stays in HMM/devm, mainly because I am not sure whether it is ok to leave the kasan calls out of lock or not. If we think that this can be done, the hotplug lock can be moved within add/del_device_memory, which would be nicer IMHO. 3) Although I think that init_currently_empty_zone should be protected by the spanlock since it touches zone_start_pfn, I decided to leave it as it is right now. The main point of moving it within the lock was to be able to move move_pfn_range_to_zone out of the hotplug lock for HMM/devm code. The main point of this patchset is to move all the page/zone handling from the hot-remove path, back to the offlining stage. In this way, we can better split up what each part does: * hot-add path: - Create a new resource for the hot-added memory - Create memory sections for the hot-added memory - Create the memblocks representing the hot-added memory * online path: - Re-adjust zone/pgdat nr of pages (managed, spanned, present) - Initialize the pages from the new memory-range - Online memory sections * offline path: - Offline memory sections - Re-adjust zone/pgdat nr of pages (managed, spanned, present) * hot-remove path: - Remove memory sections - Remove memblocks - Remove resources So, hot-add/remove stages should only care about sections and memblocks. While all the zone/page handling should belong to the online/offline stage. Another thing is that for the sake of reviewability, I split the patchset in 5 parts, but pathc3 could be combined into patch4. This patchset is based on top of mmotm. [1] https://patchwork.kernel.org/patch/10547445/ [2] https://www.spinics.net/lists/linux-mm/msg161316.html [3] https://patchwork.kernel.org/cover/10613425/ 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 | 14 +--- 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 | 11 +--- drivers/base/memory.c | 9 ++- drivers/base/node.c | 38 ++--------- include/linux/memory.h | 2 +- include/linux/memory_hotplug.h | 21 ++++-- include/linux/node.h | 9 ++- kernel/memremap.c | 13 ++-- kernel/resource.c | 16 +++++ mm/hmm.c | 35 +++++----- mm/memory_hotplug.c | 142 +++++++++++++++++++++++++---------------- mm/sparse.c | 6 +- 16 files changed, 177 insertions(+), 159 deletions(-)