Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp489294ybd; Wed, 26 Jun 2019 01:29:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCyWllQ7SNev5axtaNypEXxq3wUoy1qBks5Zlyd+Ar7joUQt6s3qMhm8z/RNZ2NxjWlzQx X-Received: by 2002:a17:902:d915:: with SMTP id c21mr4002459plz.335.1561537743960; Wed, 26 Jun 2019 01:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561537743; cv=none; d=google.com; s=arc-20160816; b=S5ons8bdTZ+cmdrtE5u4EC2atOwcaTUU9r72p03CaJDNYT+RHnM6dpolqSIIR4jsVa Ijt2sl1WfZ9ZdLPzOcvdB3YwSSDNYCbOKYudbSQCnV0tWxVTzVC5S3/cT3EOBNvMR8Cu ejocHmW+zlEUabXicm3AXaijEkXpLLlh4UL6c6OsbeDe0uN/VgmZRukCgi7SfkKEaGJv guIPfyxfNynpXmVQhk+f+0h1TMjtNLQmzWP5VWw1A8yEw1FB8O1+UIYWPZ8EACf50TB9 EsxaMWms1QBuUbX/iVMlOrZjSJSFuLWNPHW8W4QoBHlK8xgMrUQIXkY71gLSkl9hlpkW BIgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Ph9MwRYy+Iz1pQfa4GCAiuf2ZMuKsfRHps1MNfPOxQA=; b=Bv5qnXV79eXgZmvemdXfHj7Fpu/nPj9A7EeNJxbOqmF169Db4Qj9OqP9Cxj5RE4Q1e uIrbsIgd84bBKAccPBXED1Tlj7DUPCwr7jDbHCTDFSQgJU4RQXqnNSng8mGzAgSmPduj vGAsyYlFKNKeVbK2YN21VekGdhgiCXkDMX7GYxue1OsavF+i4xFrC23q0cwnH0hk7q2M 19cykUj3KkVDw8eMNhJ+f+9STNJvD4FtXKagwGXhuus1UXDfRIrAU1rwQNR4bSMt2Qpt zCuGkD5Lh4axTkeXUf0esAQvhgSNF33//cveD+W63Z/MUgzuUSKR8pdsvyFw5qNT86JZ 0xNA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97si2723110ple.161.2019.06.26.01.28.47; Wed, 26 Jun 2019 01:29:03 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726967AbfFZI2A (ORCPT + 99 others); Wed, 26 Jun 2019 04:28:00 -0400 Received: from mx2.suse.de ([195.135.220.15]:60496 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725379AbfFZI17 (ORCPT ); Wed, 26 Jun 2019 04:27:59 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id AD0FBAD7E; Wed, 26 Jun 2019 08:27:58 +0000 (UTC) Date: Wed, 26 Jun 2019 10:27:56 +0200 From: Oscar Salvador To: David Hildenbrand Cc: akpm@linux-foundation.org, mhocko@suse.com, dan.j.williams@intel.com, pasha.tatashin@soleen.com, Jonathan.Cameron@huawei.com, anshuman.khandual@arm.com, vbabka@suse.cz, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 0/5] Allocate memmap from hotadded memory Message-ID: <20190626082756.GD30863@linux> References: <20190625075227.15193-1-osalvador@suse.de> <2ebfbd36-11bd-9576-e373-2964c458185b@redhat.com> <20190626080249.GA30863@linux> <2750c11a-524d-b248-060c-49e6b3eb8975@redhat.com> <20190626081516.GC30863@linux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190626081516.GC30863@linux> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 26, 2019 at 10:15:16AM +0200, Oscar Salvador wrote: > On Wed, Jun 26, 2019 at 10:11:06AM +0200, David Hildenbrand wrote: > > Back then, I already mentioned that we might have some users that > > remove_memory() they never added in a granularity it wasn't added. My > > concerns back then were never fully sorted out. > > > > arch/powerpc/platforms/powernv/memtrace.c > > > > - Will remove memory in memory block size chunks it never added > > - What if that memory resides on a DIMM added via MHP_MEMMAP_DEVICE? > > > > Will it at least bail out? Or simply break? > > > > IOW: I am not yet 100% convinced that MHP_MEMMAP_DEVICE is save to be > > introduced. > > Uhm, I will take a closer look and see if I can clear your concerns. > TBH, I did not try to use arch/powerpc/platforms/powernv/memtrace.c > yet. > > I will get back to you once I tried it out. On a second though, it would be quite trivial to implement a check in remove_memory() that does not allow to remove memory used with MHP_MEMMAP_DEVICE in a different granularity: +static bool check_vmemmap_granularity(u64 start, u64 size); +{ + unsigned long pfn; + unsigned int nr_pages; + struct page *p; + + pfn = PHYS_PFN(start); + p = pfn_to_page(pfn); + nr_pages = size >> PAGE_SIZE; + + if (PageVmemmap(p)) { + struct page *h = vmemmap_get_head(p); + unsigned long sections = (unsigned long)h->private; + + if (sections * PAGES_PER_SECTION > nr_pages) + fail; + } + no_fail; +} + + static int __ref try_remove_memory(int nid, u64 start, u64 size) { int rc = 0; BUG_ON(check_hotplug_memory_range(start, size)); mem_hotplug_begin(); + rc = check_vmemmap_granularity(start, size); + if (rc) + goto done; The above is quite hacky, but it gives an idea. I will try the code from arch/powerpc/platforms/powernv/memtrace.c and see how can I implement a check. -- Oscar Salvador SUSE L3