Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5724813yba; Thu, 11 Apr 2019 04:34:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQHhbXWHRuJMyTOH0qBPOcehqO5ybGEXs340aS2AISyF4GqdLfpAv22rKYsZD/6p46K+uX X-Received: by 2002:a62:7603:: with SMTP id r3mr49661551pfc.32.1554982492933; Thu, 11 Apr 2019 04:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554982492; cv=none; d=google.com; s=arc-20160816; b=qIVsdw+FzrsTm0eWVmgXHtNGvRS8V1trur/VVLq1sM23ppzzKL7MHcdRlGTAjTQkrI soB3IgtEP8LtQbKeXvHtZg0X8Nsb8M2nA9VSXqNs4F+ph0Bx2FXtda7nKjQxWVor7LLh qEIFHfAl8Ajdz59rIKolHH+L4o7ViogYwJTJzfvBQyxWunPGiDa/nzO3/e+eWqZ7IFs3 K4K3grysgVkXeHnpYPVOrIfus78bQY7LeNrx+nqe35dZ/vSLe8EyJvcAAXtDIxQYN7q5 rmc+oRTCzTveZ2nLkeLgLFUr/7sAUmeoCuALgOoEvFR7a0lyQ48RyVvm9OkVle6rh/5P +Afw== 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=S7X9hV7LOt+JiE4IhDf4srG1hc8OQIEY0E8eXJdN+zM=; b=ybkZqWehAY4C2Pggq/vrSsly8pYyekoeB1lguoERQo1HPTMXSFjuDXXS29LOdxaVDy 49YQxeMGOweUKWVBOhPvkBRh3N7JCFCqy1NYGNvBaKEkzOaYjtozZDl5kR4RS4i3L7v8 g4PmhKqEbHygO+TbEdiD3szhgzHz6h8lJfDmzrJ+7FyTsop+oHYMX4u8QsrA+E0sODFn oxKVhg8fXuAs1g9A0jOYtWZqQVEhpOHNSUkM6Ghy6NWO6BF6bt8ZR6V0MkpGenims8Dw +ICV4SOamWm4rUjCsBiiaZV0lCmzPBk4JFqLSkMpyXITnLsbFGh/bYslpqmctVI8nGPp Kg8w== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k4si34433176pll.170.2019.04.11.04.34.37; Thu, 11 Apr 2019 04:34:52 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726875AbfDKLcI (ORCPT + 99 others); Thu, 11 Apr 2019 07:32:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:59120 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726599AbfDKLcI (ORCPT ); Thu, 11 Apr 2019 07:32:08 -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 36B57AC5B; Thu, 11 Apr 2019 11:32:07 +0000 (UTC) Date: Thu, 11 Apr 2019 13:32:06 +0200 From: Michal Hocko To: David Hildenbrand Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Oscar Salvador , Pavel Tatashin , Wei Yang , Qian Cai , Arun KS , Mathieu Malaterre Subject: Re: [PATCH] mm/memory_hotplug: Drop memory device reference after find_memory_block() Message-ID: <20190411113206.GU10383@dhcp22.suse.cz> References: <20190410101455.17338-1-david@redhat.com> <20190411084141.GQ10383@dhcp22.suse.cz> <0bbe632f-cb85-4a98-0c79-ded11cf39081@redhat.com> <20190411105617.GS10383@dhcp22.suse.cz> <711db571-ee39-eb64-4551-baaa5b562579@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <711db571-ee39-eb64-4551-baaa5b562579@redhat.com> 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 Thu 11-04-19 13:18:07, David Hildenbrand wrote: > On 11.04.19 12:56, Michal Hocko wrote: > > On Thu 11-04-19 11:11:05, David Hildenbrand wrote: > >> On 11.04.19 10:41, Michal Hocko wrote: > >>> On Wed 10-04-19 12:14:55, David Hildenbrand wrote: > >>>> While current node handling is probably terribly broken for memory block > >>>> devices that span several nodes (only possible when added during boot, > >>>> and something like that should be blocked completely), properly put the > >>>> device reference we obtained via find_memory_block() to get the nid. > >>> > >>> The changelog could see some improvements I believe. (Half) stating > >>> broken status of multinode memblock is not really useful without a wider > >>> context so I would simply remove it. More to the point, it would be much > >>> better to actually describe the actual problem and the user visible > >>> effect. > >>> > >>> " > >>> d0dc12e86b31 ("mm/memory_hotplug: optimize memory hotplug") has started > >>> using find_memory_block to get a nodeid for the beginnig of the onlined > >>> pfn range. The commit has missed that the memblock contains a reference > >>> counted object and a missing put_device will leak the kobject behind > >>> which ADD THE USER VISIBLE EFFECT HERE. > >>> " > >> > >> I don't think mentioning the commit a second time is really needed. > >> > >> " > >> Right now we are using find_memory_block() to get the node id for the > >> pfn range to online. We are missing to drop a reference to the memory > >> block device. While the device still gets unregistered via > >> device_unregister(), resulting in no user visible problem, the device is > >> never released via device_release(), resulting in a memory leak. Fix > >> that by properly using a put_device(). > >> " > > > > OK, sounds good to me. I was not sure about all the sysfs machinery > > and the kobj dependencies but if there are no sysfs files leaking and > > crashing upon a later access then a leak of a small amount of memory > > that is not user controlable then this is not super urgent. > > > > Thanks! > > I think it can be triggered by onlining/offlining memory in a loop. which is a privileged operation so the impact is limited. > But as you said, only leaks of small amount of memory. Yes, as long as there are no other side sysfs related effects. -- Michal Hocko SUSE Labs