Received: by 2002:aa6:c3ca:0:b029:c8:4414:5686 with SMTP id b10csp1810424lkq; Fri, 19 Mar 2021 12:26:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGl7ORVZNWtEDj1svOiiytg4+ihAd0m+9aUamtoZUYCtG07cFwY2MaKg81gTwgwiZ9PQek X-Received: by 2002:a17:906:da0e:: with SMTP id fi14mr6386265ejb.188.1616181988057; Fri, 19 Mar 2021 12:26:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616181988; cv=none; d=google.com; s=arc-20160816; b=QLsO04ChVPG9Wwhk9jRJXY4eFPy+dPpsMXGlF81OejML6FR1gUBSSN/cZ4Gm3Ryzw9 yByuUxrIxDqrSx0G5ZbovjIlHGSfbVkAz/kEACZxkyUJ92GUhBG8YSF5pcgVa2lZSz4L NV4gUzCZ4ry1bcVTexLGWnmnaf61rBTwkIfYd1nLnOvBIk/a0oonGtm30wvwMPGjL3Uw z8Fzx2ZZJv8FO2jG/uU1uQsnAVEt2Jxvsyo37mm7aEPdiZUNAm52pbxIkHtHZ7P88+ak jO/WbcB4Ka2BUpSqt/EPYQG12OLuLPHNirmAhAzff85IE4GRUxxXDhJ7SWWrt4tES/H+ 7Hhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=vi3OhCV5xHRkQ6K9sU0vs2DTIjIbNhVBKwX3Itgewtw=; b=faQ/T7oe6PH9BNTOCuq0Ko3d8sYgvz0lvpkj+7aNhEDr2OFRxtNlf+JDhCVSMCVdSe EwyPv0gBkdYSNjGHqN2pG16rUoSN3FAy/RWhetmsfhIEz8xcwIoWn1o49pUOM2NPdx7t vBY4oiemPizdmdD8QJSfROwHRMSxn53NeJDRG7lI3mTi+fLeiyk3tHjUQLsAKxS0QuM+ Ok/CBsGTg7FtCCD4gf9FPg4oV88dzzpNZZse1j74qDPSKoqzWK7Kypimq7MmORLGkVlS gFbnN2Qfb0VHN1HZPhtj8y1qBh4EUvSgX4579VQtdI6kIQZzVnibFWXhaK87be3+sp31 Y31g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Y3anoUmz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw1si5180808edb.412.2021.03.19.12.26.04; Fri, 19 Mar 2021 12:26:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Y3anoUmz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230391AbhCSTYe (ORCPT + 99 others); Fri, 19 Mar 2021 15:24:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230142AbhCSTYG (ORCPT ); Fri, 19 Mar 2021 15:24:06 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BCA2C06174A; Fri, 19 Mar 2021 12:24:06 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id x28so11669383lfu.6; Fri, 19 Mar 2021 12:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=vi3OhCV5xHRkQ6K9sU0vs2DTIjIbNhVBKwX3Itgewtw=; b=Y3anoUmzvmht5ZeuS0K6pBMLsHIyBTiT+FQokPOsvcNHziSdnJEQ8yslfdisJ5QOsa vXMDxQliBqYnos7M/g2MR9lXqjifBxNXgBdDr/irEv/ELG9pGPn0QuMbCATBToqI2iSj 5R0GdQfAr6f/2/47cD+v2zcedeKJA3tdhD+OyZQSCeq+Li6RyP/aljJGff2T0H9a1kNP y9f9BbBxCyR4JTz1ikuQ0zzOpICj6Q2vMRMmPdOUdVa31yjL7ybMAMkmP3O8+eAyNo/E BWAKNQcJqiI3n6Bhu8um3h/HiqARF9SKKJvlaf+44jk7ZT7BG115og8ZOrjkhRp5Y5Y0 0pmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=vi3OhCV5xHRkQ6K9sU0vs2DTIjIbNhVBKwX3Itgewtw=; b=Rw/pla4G6vhYaSYFgRxz2Q75uJfjQ5pUItUjkTye1ETgbzZviuOuf7DkdJ0bypDBjT 938sJsobO16wTO1XzPvdZEavsHOXlcn3AlIv6DnmlJRakuBWVpWxvJ0sm1RWspmiBKIM DP24ewF8w8UhQhLhGFu+9nVmzg7cCsUIyQMEA5LxWG5ekMJZC2ekKlAtopbJyVydl9Ct F/yhZ61czxPmdfMjU0rF/Bwv5Zk615B8jy0VWtCkaODO26ofbykYc9hBWqGEWU3w83Do Vo3k6TudY6zS04CgdbHq6zU21oMh1QXFxGhEWubPiSB06HMUrmc4EwsQo18/a5M73Aok WKTw== X-Gm-Message-State: AOAM53248En4fZy0KigeX9Zz3St2uCp4lp4vrePj+juI9vOcdfUF0Mjy IT/j2sORi3/3cyofHVoiSBLBwNxL18Y= X-Received: by 2002:a19:40c7:: with SMTP id n190mr1689219lfa.378.1616181844579; Fri, 19 Mar 2021 12:24:04 -0700 (PDT) Received: from [192.168.2.145] (109-252-193-52.dynamic.spd-mgts.ru. [109.252.193.52]) by smtp.googlemail.com with ESMTPSA id m24sm717293lfq.184.2021.03.19.12.24.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Mar 2021 12:24:04 -0700 (PDT) Subject: Re: [PATCH v4] mm: cma: support sysfs To: Minchan Kim , Greg Kroah-Hartman Cc: Andrew Morton , linux-mm , LKML , joaodias@google.com, willy@infradead.org, david@redhat.com, surenb@google.com, John Hubbard , Nicolas Chauvet , "linux-tegra@vger.kernel.org" References: <33ec18ef-8652-643a-1a53-ff7c3caf4399@gmail.com> <78883205-e6da-5bc4-dcec-b6eb921567b1@gmail.com> <72db59eb-75dc-d1ed-7a83-17052e8f22a8@gmail.com> <071c6681-f492-2c94-5686-30c30778f39d@gmail.com> <007c0317-8819-a6b8-fdff-c0b5899c4f51@gmail.com> From: Dmitry Osipenko Message-ID: Date: Fri, 19 Mar 2021 22:24:03 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 19.03.2021 22:03, Minchan Kim пишет: > On Fri, Mar 19, 2021 at 09:48:11PM +0300, Dmitry Osipenko wrote: >> 19.03.2021 21:21, Minchan Kim пишет: >>> On Fri, Mar 19, 2021 at 08:56:06PM +0300, Dmitry Osipenko wrote: >>>> 19.03.2021 19:30, Minchan Kim пишет: >>>>> +static void cma_kobj_release(struct kobject *kobj) >>>>> +{ >>>>> + struct cma_kobject *cma_kobj = container_of(kobj, struct cma_kobject, kobj); >>>>> + >>>>> + kfree(cma_kobj); >>>>> +} >>>> >>>> Oh, wait.. I think this kfree wrong since cma_kobj belongs to the array. >>> >>> Oh, good spot. Let me use kzalloc. >>> >> >> Thinking a bit more about this.. it looks like actually it should be >> better to get back to the older variant of cma_stat, but allocate at the >> time of CMA initialization, rather than at the time of sysfs >> initialization. Then the cma_stat will be decoupled from the cma struct > > IIRC, the problem was slab was not initiaized at CMA init point. > That's why I liked your suggestion. Alright, if CMA init time is a problem, then the recent variant should be okay. >> and cma_stat will be a self-contained object. > > Yeah, self-contained is better but it's already weird to > have differnt lifetime for one object since CMA object > never die, technically. > Indeed. I found the Greg's original argument and not sure that it's really worthwhile to worry about the copycats since this is not a driver's code.. Maybe we could just add a clarifying comment for the kobj, telling why it's okay for CMA. Greg, doesn't it sound like a good compromise to you?