Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp906140pxb; Tue, 9 Feb 2021 16:14:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZgye9ua8WT1YtKgnSfTXcvI82HoOFCkCflagqp2/pDWScNNOnQ7odzziHZBmqZPZW5UJa X-Received: by 2002:a17:906:c448:: with SMTP id ck8mr261568ejb.55.1612916066819; Tue, 09 Feb 2021 16:14:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612916066; cv=none; d=google.com; s=arc-20160816; b=hTDMCkzwg7TqIp6LSrD7xUH3M2qS7Eaha0TcCj94AJg8gIOQk5/4MyT3o/SbK5mnFi uYic2pnY653hrGQnjWknYcHiwiIyOtLdTf0ATjWppPeu1oLp5Hl8YQMY3PQhs1AlPe1O tZq5C7EQos7W+kT5xuOD+ZoTT/DOiNLG9Q2RwrMm2WevzL9W6TSSh8949HOBCR5LkWxJ BruJdkZaf4WGpAlSskP8fQSDeHKbCc0MlBSt2rhhr1DJHHp/HSbYFJtJeRoT+CzizGUb WBLDO2YPcD4LsA71y9gC/TPDxRabkfDqdwURtUfFhydC8YY14rQzSZI8P5YmN4FdvoIC T0/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=2AO1RfSdot2l4/kEHEEeNwPcUFdS4l5FvkUJO30yA5w=; b=ef3k9vp5qXkCdJL7CYXWdiQfb/Xsx+g6G/zGc5I/r6Cq99J3gYWK00WDVgpct9IFi7 67kfW2RQ+pYyl0tu+2f4QJCOIBVnRXQCZ+zdXxLHvPOv2cTBCDI6t090x3b/rx/15Z8x cTNKpQksqtI1Ofcxuf6hfsV51qwyPRN7gBl83FIfV+sUmizyMVXn/42Ld+vjJaeLL31e lia9fXS270ilMcFo7rkQjGtSAsRbCic8h/HeiYk0aBhRZk45t7mVO1scN1hJ/+s8dnbW KIHe5hIOPmQUqSjQYTkmMTwqI/bFr5u6o6NneDNIw9TTL8vHmQKWV7c1uWVAR+CA1Rio eFqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=eX8YLtu+; 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=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t22si148514ejf.399.2021.02.09.16.14.02; Tue, 09 Feb 2021 16:14:26 -0800 (PST) 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=@nvidia.com header.s=n1 header.b=eX8YLtu+; 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=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234876AbhBJAKd (ORCPT + 99 others); Tue, 9 Feb 2021 19:10:33 -0500 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:11828 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233848AbhBIUkF (ORCPT ); Tue, 9 Feb 2021 15:40:05 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Tue, 09 Feb 2021 12:11:21 -0800 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 9 Feb 2021 20:11:21 +0000 Received: from [10.2.50.67] (172.20.145.6) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 9 Feb 2021 20:11:21 +0000 Subject: Re: [PATCH v2] mm: cma: support sysfs To: Greg KH , Minchan Kim CC: Andrew Morton , linux-mm , LKML , , , References: <20210208180142.2765456-1-minchan@kernel.org> <43cd6fc4-5bc5-50ec-0252-ffe09afd68ea@nvidia.com> <7cc229f4-609c-71dd-9361-063ef1bf7c73@nvidia.com> From: John Hubbard Message-ID: <09e60732-6a46-dd00-f9d5-4ef17ee685c8@nvidia.com> Date: Tue, 9 Feb 2021 12:11:20 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:85.0) Gecko/20100101 Thunderbird/85.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To DRHQMAIL107.nvidia.com (10.27.9.16) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1612901481; bh=2AO1RfSdot2l4/kEHEEeNwPcUFdS4l5FvkUJO30yA5w=; h=Subject:To:CC:References:From:Message-ID:Date:User-Agent: MIME-Version:In-Reply-To:Content-Type:Content-Language: Content-Transfer-Encoding:X-Originating-IP:X-ClientProxiedBy; b=eX8YLtu+rXVa6V/RAb+Nce5VU6xVaHO0SVuW0vo8cmNnZnwOwWv9Krx45hYgXWVRw cK+9crYqCJAjfvjRw6rVrWc95c4rbA9p5jP0JnkM8O9HT2JTpe+MNOEJPdUS/lfVok golIF49EEy587Dxoy2I3sf9XPh16r7foNdNox2b8PWbngG9VpMXrrbFf0P1WGJaGbX ZXFwHLRkximsTmFiaW2MAV8ZIsShk5frVKh3YsT1YSD65vEI+c6vV0GQxvxhHascBy bXfiEctIjVp3IKYcMioWq5q8Uiw9cQAaSYklHJ+405rp3X8WRFpgv7udteoQB32Ww0 3aGF2CVtpk75A== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/9/21 9:49 AM, Greg KH wrote: >>> That's fine if you want to add it to the parent. If so, then the >>> kobject controls the lifetime of the structure, nothing else can. >> >> The problem was parent object(i.e., struct cma cma_areas) is >> static arrary so kobj->release function will be NULL or just >> dummy. Is it okay? I thought it was one of the what you wanted >> to avoid it. > > No, that is not ok. > >>> Either is fine with me, what is "forbidden" is having a kobject and >>> somehow thinking that it does not control the lifetime of the structure. >> >> Since parent object is static arrary, there is no need to control the >> lifetime so I am curious if parent object approach is okay from kobject >> handling point of view. > > So the array is _NEVER_ freed? If not, fine, don't provide a release > function for the kobject, but ick, just make a dynamic kobject I don't > see the problem for something so tiny and not very many... > Yeah, I wasn't trying to generate so much discussion, I initially thought it would be a minor comment: "just use an embedded struct and avoid some extra code", at first. > I worry that any static kobject might be copied/pasted as someone might > think this is an ok thing to do. And it's not an ok thing to do. > Overall, then, we're seeing that there is a small design hole: in order to use sysfs most naturally, you either much provide a dynamically allocated item for it, or you must use the static kobject, and the second one sets a bad example. I think we should just use a static kobject, with a cautionary comment to would-be copy-pasters, that explains the design constraints above. That way, we still get a nice, less-code implementation, a safe design, and it only really costs us a single carefully written comment. thanks, -- John Hubbard NVIDIA