Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5697739yba; Thu, 11 Apr 2019 03:58:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVpD9UE7YX7ovh5gxhJiU//559DI4AacpZ3j48imaKpT2DGfv2OGqD41Da+2Beop9VJX1p X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr49776012plo.8.1554980321835; Thu, 11 Apr 2019 03:58:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554980321; cv=none; d=google.com; s=arc-20160816; b=teZP4rN5C8OphzKt3BrLz0Ep83Lf9QnAyOtoSLqypEsc4bJxAi+nxtvRT/JzhrEyU6 PbNweb/nvsRA6zAlQOqWmNXYvYWxAtxVo7a0A70jp/kCfjEVIlVi5+VhrKbab9tHkeb7 gqzYlEuzQQ+6YEqrLd+3ialmcC7ReveP/H83rAyFRvIxhJq/9cQinPtU2X6N+zhoxC8z 28zawgwpIcHOJwNsGQZZICsfGm2wVOKlkWQD2ZenziiBGWZxN2fQV6v0EpKX7xHm7JXQ 8Lgi+8WIlL/4k2CY0Un/FcSes24gwMfFEXkoU5A6LIGHyqEVsrjTX/cVO1RwA0f4wS2B NF8A== 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=Q9l4I5pQ1tPLFiOxAuLKL3TeAsjjhqRb4S0f7sdrzoo=; b=jB1F2cRHjTSOU6pwja8U8q+oIBLB39xA5SWKalzvWCj5mYcw4i7w52Kolyc3pOHf7M qjXtqZ3M14n6eLl61QTMGhYyk9eDcVrqtfSMbpFQneR421pwiO2FJ3UD7W8//yLzZMEi UlBNc7wOVc/WKi6mp5BQ37h4e6fKZ9iBXHxCDkZuvCLL0aduQtABDGkdqTB23F3OB9Ii sGZOaqZ9/Gq8UufR4QZ9vjqQWzN5ztRKsCyBdxm+EpQhpHQE52ibMamS3CqJ3TVEPsLk eNhdxZUCnfaZ9KxAC0YuYR7ruu43LZaq5o7lA2EFRics7l6w8hbqCcEndKhH1/h724OB BJiw== 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 p22si34621063pgi.449.2019.04.11.03.58.26; Thu, 11 Apr 2019 03:58:41 -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 S1726732AbfDKK4W (ORCPT + 99 others); Thu, 11 Apr 2019 06:56:22 -0400 Received: from mx2.suse.de ([195.135.220.15]:39968 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726628AbfDKK4V (ORCPT ); Thu, 11 Apr 2019 06:56:21 -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 2CF44ABAC; Thu, 11 Apr 2019 10:56:20 +0000 (UTC) Date: Thu, 11 Apr 2019 12:56:17 +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: <20190411105617.GS10383@dhcp22.suse.cz> References: <20190410101455.17338-1-david@redhat.com> <20190411084141.GQ10383@dhcp22.suse.cz> <0bbe632f-cb85-4a98-0c79-ded11cf39081@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0bbe632f-cb85-4a98-0c79-ded11cf39081@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 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! -- Michal Hocko SUSE Labs