From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29EC0C433DB for ; Tue, 9 Feb 2021 20:11:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A3B6464EC8 for ; Tue, 9 Feb 2021 20:11:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A3B6464EC8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E82F26B0005; Tue, 9 Feb 2021 15:11:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E346F6B006C; Tue, 9 Feb 2021 15:11:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D70FD6B006E; Tue, 9 Feb 2021 15:11:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0227.hostedemail.com [216.40.44.227]) by kanga.kvack.org (Postfix) with ESMTP id C23E66B0005 for ; Tue, 9 Feb 2021 15:11:23 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8D0F8824556B for ; Tue, 9 Feb 2021 20:11:23 +0000 (UTC) X-FDA: 77799824046.30.queen51_171557d2760a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 6588C180A885F for ; Tue, 9 Feb 2021 20:11:23 +0000 (UTC) X-HE-Tag: queen51_171557d2760a X-Filterd-Recvd-Size: 4588 Received: from hqnvemgate25.nvidia.com (hqnvemgate25.nvidia.com [216.228.121.64]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Tue, 9 Feb 2021 20:11:22 +0000 (UTC) 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== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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