Received: by 10.223.164.202 with SMTP id h10csp1924039wrb; Mon, 27 Nov 2017 09:16:07 -0800 (PST) X-Google-Smtp-Source: AGs4zMYKMFXHbdOECklEAsAgmEnMBqYZl7wyXOvAIHjkJDv9AJB6PMH80ExDWWsDGIkvpORxPGDe X-Received: by 10.159.216.142 with SMTP id s14mr32700823plp.173.1511802967207; Mon, 27 Nov 2017 09:16:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511802967; cv=none; d=google.com; s=arc-20160816; b=mol7ZSb3puA8WCS0mUatIm5lg7OjzmUh3NTrX5tF3yzcg4R1J7teDN0x+W+YrzVo4F rI847a4rb4svUJ8YByIv86VVIFuzHst/waGQih50ivnkRqorW/x2riuP+vvO5eqVkxvl KQfKAAQ0dfGR0xhuSxTImmzskuaku6b5l9wV/dpOYNhAXCA4jroVLVAfwnUkvDOc118l Lw9++WVQ5hBu0WHfBDzBpxe2pzdNKWyAJ6tsWrQGXN3M97jH44xhhjpZpMh5i1jP06+j AVhbVm81p2+XeIHcHpeMx7GjmD1IzMDVPkDJvzaVlkTF8MXFdlliskVHFzmH0atZehfn 5uGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:subject:cc:to:from:date :arc-authentication-results; bh=vHe+Asbky6RdQLb+GQAvlfTBznECxW/gUPXCCBzJlXk=; b=i7JoLq/4+rdAtsev19imTFBfrdc4KBQ/UxOcebhpS6BWDANMOLHUx7UbFKIva3iU2w TqJcANb6dZpFLOcbeAndhqSgHTc+lWX95W7sWtEaXiob6MlFQc9pFgQWX2kTsD6acF/F Q4BSpY4zhnqkMdt4KcRVhS232DVApvwP6ZM3VVnuTo1FEv5BQIqnp1/ZQKWgXP3BHkbq v/BY+3qYsPrf5Y6hk+dJ1KKXF2Beo6xPBLjVxN4p5KB31efeXBKQqOjLpPwXCd37Vjn3 hIczWDsuCnYEIN1auP2TAQ1TdQap6eIX/0ZMCfjbK25dOqZZl+BKMpyQZucdqRpjH7zV zQoA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si23866869pla.339.2017.11.27.09.15.55; Mon, 27 Nov 2017 09:16:07 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753878AbdK0RO6 (ORCPT + 78 others); Mon, 27 Nov 2017 12:14:58 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44090 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753621AbdK0ROy (ORCPT ); Mon, 27 Nov 2017 12:14:54 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vARHCGOW060177 for ; Mon, 27 Nov 2017 12:14:53 -0500 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2egm4r0u28-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 27 Nov 2017 12:14:53 -0500 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 27 Nov 2017 17:14:50 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 27 Nov 2017 17:14:46 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vARHEj9L26738900; Mon, 27 Nov 2017 17:14:45 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B8D89A404D; Mon, 27 Nov 2017 17:09:19 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4BF41A405B; Mon, 27 Nov 2017 17:09:19 +0000 (GMT) Received: from samekh (unknown [9.162.48.51]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 27 Nov 2017 17:09:19 +0000 (GMT) Date: Mon, 27 Nov 2017 17:14:43 +0000 From: Andrea Reale To: Robin Murphy Cc: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, realean2@ie.ibm.com, mhocko@suse.com, m.bielski@virtualopensystems.com, scott.branden@broadcom.com, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, arunks@qti.qualcomm.com, qiuxishi@huawei.com Subject: Re: [PATCH v2 4/5] mm: memory_hotplug: Add memory hotremove probe device References: <22d34fe30df0fbacbfceeb47e20cb1184af73585.1511433386.git.ar@linux.vnet.ibm.com> <198063b0-fcc9-7beb-7476-86ed5f04734c@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <198063b0-fcc9-7beb-7476-86ed5f04734c@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 17112717-0040-0000-0000-000003F30FCD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17112717-0041-0000-0000-000025F5EA8A Message-Id: <20171127171441.GB12687@samekh> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-27_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711270231 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Robin, On Mon 27 Nov 2017, 15:33, Robin Murphy wrote: > On 23/11/17 11:14, Andrea Reale wrote: > >Adding a "remove" sysfs handle that can be used to trigger > >memory hotremove manually, exactly simmetrically with > >what happens with the "probe" device for hot-add. > > > >This is usueful for architecture that do not rely on > >ACPI for memory hot-remove. > > Is there a real-world use-case for this, or is it mostly just a handy > development feature? > as I was saying in a response to your previous message, in our use case remove events are triggered by software. Besides our use case, yes, it is mostly just a handy develeopment feature AFAICT. > >Signed-off-by: Andrea Reale > >Signed-off-by: Maciej Bielski > >--- > > drivers/base/memory.c | 34 +++++++++++++++++++++++++++++++++- > > 1 file changed, 33 insertions(+), 1 deletion(-) > > > >diff --git a/drivers/base/memory.c b/drivers/base/memory.c > >index 1d60b58..8ccb67c 100644 > >--- a/drivers/base/memory.c > >+++ b/drivers/base/memory.c > >@@ -530,7 +530,36 @@ memory_probe_store(struct device *dev, struct device_attribute *attr, > > } > > static DEVICE_ATTR(probe, S_IWUSR, NULL, memory_probe_store); > >-#endif > >+ > >+#ifdef CONFIG_MEMORY_HOTREMOVE > >+static ssize_t > >+memory_remove_store(struct device *dev, > >+ struct device_attribute *attr, const char *buf, size_t count) > >+{ > >+ u64 phys_addr; > >+ int nid, ret; > >+ unsigned long pages_per_block = PAGES_PER_SECTION * sections_per_block; > >+ > >+ ret = kstrtoull(buf, 0, &phys_addr); > >+ if (ret) > >+ return ret; > >+ > >+ if (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1)) > >+ return -EINVAL; > >+ > >+ nid = memory_add_physaddr_to_nid(phys_addr); > > This call looks a bit odd, since you're not doing a memory add. In fact, any > memory being removed should already be fully known-about, so AFAICS it > should be simple to get everything you need to know (including potentially > the online status as mentioned earlier), through 'normal' methods, e.g. > page_to_nid() or similar. Makes sense. Suggestion noted, thanks. > Robin. > > >+ ret = lock_device_hotplug_sysfs(); > >+ if (ret) > >+ return ret; > >+ > >+ remove_memory(nid, phys_addr, > >+ MIN_MEMORY_BLOCK_SIZE * sections_per_block); > >+ unlock_device_hotplug(); > >+ return count; > >+} > >+static DEVICE_ATTR(remove, S_IWUSR, NULL, memory_remove_store); > >+#endif /* CONFIG_MEMORY_HOTREMOVE */ > >+#endif /* CONFIG_ARCH_MEMORY_PROBE */ > > #ifdef CONFIG_MEMORY_FAILURE > > /* > >@@ -790,6 +819,9 @@ bool is_memblock_offlined(struct memory_block *mem) > > static struct attribute *memory_root_attrs[] = { > > #ifdef CONFIG_ARCH_MEMORY_PROBE > > &dev_attr_probe.attr, > >+#ifdef CONFIG_MEMORY_HOTREMOVE > >+ &dev_attr_remove.attr, > >+#endif > > #endif > > #ifdef CONFIG_MEMORY_FAILURE > > > From 1585233891286736917@xxx Mon Nov 27 15:34:07 +0000 2017 X-GM-THRID: 1584855261784805699 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread