Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2239175ybf; Mon, 2 Mar 2020 04:53:46 -0800 (PST) X-Google-Smtp-Source: ADFU+vsysrKhTfVXzQVBto2ItE1ZeCEAb+vMJfVRfQR+/OBLLDFRyXx6tOt3neXX4OigBZ4Ta88b X-Received: by 2002:aca:a98a:: with SMTP id s132mr5337865oie.141.1583153626530; Mon, 02 Mar 2020 04:53:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583153626; cv=none; d=google.com; s=arc-20160816; b=tfUrTdMOvDmV+WAICzLIy6jKDx7lyBGO/XOzy8L5uFjgQlqzl4Yze8jEM9w3F0XcoZ pb0xxExDgk5CfdFOkO3LwVmfvwha36QbFCWHJAv4Ak/CbRWWxgJijedZ7ztriQ/zzj7e u8Jm7rcmr/ojpOWlbFZyd+Scf5ZcyBCV4bXApLOLf3uWh9XrWrW5Sh9y68lOUugF2V2O iKKbRBiKHhFU/5/U4g82UCQmH0WolwbvALS+VEp9AareGHRb4uu6Lj0Nv1A/7vgLP91Y AdO3hYCZgY8Xf6ZTEIIRd63Z+haiZxri5jfoZslrddr73K8QVN0GCnbURqjqqbWkf3SX b24A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:autocrypt:from:references:cc:to:subject :dkim-signature; bh=9PtSLdZCaRnvpSBdCFBQ5RSyzQpwkCGpqNVbV6e41Lg=; b=NgDKHXhJsbe5w2YMQjgmqfH3ClZq85E6YVAH6QTNEt9VdVL4uQss1A9AI2cosd3+bi wrL7+YsHjRsA/32WsXXbniEZAy6XJou3h3VgRWa6uCWSeQoTcMX8Da3MCZdwvq+lrD9d VNOZc23DxK2dWnoxdLJof0nRDIs+qOWDXbP8JkKEP/VQgzgLbjbYPJ1hr86xOSKMiAV6 s8/Yix1/dxluQcivvKSUYNlDNxw+HmKU1Raq3XjiIpYYLpDnFejtQziqWLTJUfVdVASB uuPtZgqyrVXduQnXsjXuYhWq5swXWZeigneTxOtD3h06PhaaAuGjwYaSNOoavTSNRPea rQmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LUYOxDtV; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j20si6329528otp.147.2020.03.02.04.53.34; Mon, 02 Mar 2020 04:53:46 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LUYOxDtV; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727820AbgCBMxZ (ORCPT + 99 others); Mon, 2 Mar 2020 07:53:25 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:56815 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727267AbgCBMxY (ORCPT ); Mon, 2 Mar 2020 07:53:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583153603; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=9PtSLdZCaRnvpSBdCFBQ5RSyzQpwkCGpqNVbV6e41Lg=; b=LUYOxDtVgXpyRAKj8BstfLHdjlBy47J+/c1KjotufOoIQnsJ6zLTDKnxn03G7pHHZsN6T4 nRL1aRbNh5UySl+ryZAgNzsbU9ckH+60LDgnl1he9nlp+XuTmbF4pc24Y4Y9xno2jwz3TZ SyvfsUKznofEMu0G+MN0ooHpsDGm9Oc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-205-TwRprTWlNmCszp0mRNiWlg-1; Mon, 02 Mar 2020 07:53:20 -0500 X-MC-Unique: TwRprTWlNmCszp0mRNiWlg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9395B8017DF; Mon, 2 Mar 2020 12:53:17 +0000 (UTC) Received: from [10.36.116.114] (ovpn-116-114.ams2.redhat.com [10.36.116.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21EB9100E805; Mon, 2 Mar 2020 12:53:08 +0000 (UTC) Subject: Re: [PATCH RFC v4 08/13] mm/memory_hotplug: Introduce offline_and_remove_memory() To: Michal Hocko Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtio-dev@lists.oasis-open.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, Andrew Morton , "Michael S . Tsirkin" , Oscar Salvador , Pavel Tatashin , Wei Yang , Dan Williams , Qian Cai References: <20191212171137.13872-1-david@redhat.com> <20191212171137.13872-9-david@redhat.com> <20200225141134.GU22443@dhcp22.suse.cz> <20200302124852.GJ4380@dhcp22.suse.cz> From: David Hildenbrand Autocrypt: addr=david@redhat.com; prefer-encrypt=mutual; keydata= mQINBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpi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qLt7/oz/5deGuwxgb65pWIzufa N7eop7uh+6bezi+rugUI+w6DABEBAAGJAiUEGAECAA8FAlXLn5ECGwwFCQlmAYAACgkQTd4Q 9wD/g1qA6w/+M+ggFv+JdVsz5+ZIc6MSyGUozASX+bmIuPeIecc9UsFRatc91LuJCKMkD9Uv GOcWSeFpLrSGRQ1Z7EMzFVU//qVs6uzhsNk0RYMyS0B6oloW3FpyQ+zOVylFWQCzoyyf227y GW8HnXunJSC+4PtlL2AY4yZjAVAPLK2l6mhgClVXTQ/S7cBoTQKP+jvVJOoYkpnFxWE9pn4t H5QIFk7Ip8TKr5k3fXVWk4lnUi9MTF/5L/mWqdyIO1s7cjharQCstfWCzWrVeVctpVoDfJWp 4LwTuQ5yEM2KcPeElLg5fR7WB2zH97oI6/Ko2DlovmfQqXh9xWozQt0iGy5tWzh6I0JrlcxJ ileZWLccC4XKD1037Hy2FLAjzfoWgwBLA6ULu0exOOdIa58H4PsXtkFPrUF980EEibUp0zFz GotRVekFAceUaRvAj7dh76cToeZkfsjAvBVb4COXuhgX6N4pofgNkW2AtgYu1nUsPAo+NftU CxrhjHtLn4QEBpkbErnXQyMjHpIatlYGutVMS91XTQXYydCh5crMPs7hYVsvnmGHIaB9ZMfB njnuI31KBiLUks+paRkHQlFcgS2N3gkRBzH7xSZ+t7Re3jvXdXEzKBbQ+dC3lpJB0wPnyMcX FOTT3aZT7IgePkt5iC/BKBk3hqKteTnJFeVIT7EC+a6YUFg= Organization: Red Hat GmbH Message-ID: Date: Mon, 2 Mar 2020 13:53:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200302124852.GJ4380@dhcp22.suse.cz> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02.03.20 13:48, Michal Hocko wrote: > On Tue 25-02-20 15:27:28, David Hildenbrand wrote: >> On 25.02.20 15:11, Michal Hocko wrote: >>> On Thu 12-12-19 18:11:32, David Hildenbrand wrote: >>>> virtio-mem wants to offline and remove a memory block once it unplugged >>>> all subblocks (e.g., using alloc_contig_range()). Let's provide >>>> an interface to do that from a driver. virtio-mem already supports to >>>> offline partially unplugged memory blocks. Offlining a fully unplugged >>>> memory block will not require to migrate any pages. All unplugged >>>> subblocks are PageOffline() and have a reference count of 0 - so >>>> offlining code will simply skip them. >>>> >>>> All we need an interface to trigger the "offlining" and the removing in a >>>> single operation - to make sure the memory block cannot get onlined by >>>> user space again before it gets removed. >>> >>> Why does that matter? Is it really likely that the userspace would >>> interfere? What would be the scenario? >> >> I guess it's not that relevant after all (I think this comment dates >> back to the times where we didn't have try_remove_memory() and could >> actually BUG_ON() in remove_memory() if there would have been a race). >> Can drop that part. >> >>> >>> Or is still mostly about not requiring callers to open code this general >>> patter? >> >> From kernel module context, I cannot get access to the actual memory >> block device (find_memory_block()) and call the device_unregister(). >> >> Especially, also the device hotplug lock is not exported. So this is a >> clean helper function to be used from kernel module context. (e.g., also >> hyper-v showed interest for using that) > > Fair enough. > I'll send a v1 shortly, I rephrased the description to make this clear. Thanks! -- Thanks, David / dhildenb