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.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 CB1BAC433C1 for ; Fri, 19 Mar 2021 15:50:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 449B661958 for ; Fri, 19 Mar 2021 15:50:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 449B661958 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9E6388D0006; Fri, 19 Mar 2021 11:50:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9BE398D0001; Fri, 19 Mar 2021 11:50:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D3198D0006; Fri, 19 Mar 2021 11:50:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0045.hostedemail.com [216.40.44.45]) by kanga.kvack.org (Postfix) with ESMTP id 736818D0001 for ; Fri, 19 Mar 2021 11:50:58 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 328E7180286F9 for ; Fri, 19 Mar 2021 15:50:58 +0000 (UTC) X-FDA: 77937062196.01.09D96A7 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf16.hostedemail.com (Postfix) with ESMTP id D7D9580194F3 for ; Fri, 19 Mar 2021 15:50:47 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 4A92C61958; Fri, 19 Mar 2021 15:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616169041; bh=ubgyaS52WDrIeXP4WAzmN7Ns+7FkMbsDSRneZqCrO5s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qBKpkhyXn7CE4/KIyveBBfszOXoMe+0PCvq55IQQUA1lpCCRVKS5mC9RTJj2BtFOL aZPbWpI7ZW+klAKLIqiU05jkHbPFbEsG0e24r7TsEPVfdVtxYMUZvedvcSc8b2yg+o H/UfuJ0c3sd1GCXqzoog+WtB9MwkX4QixWzDUzrg= Date: Fri, 19 Mar 2021 16:50:39 +0100 From: Greg Kroah-Hartman To: Dmitry Osipenko Cc: Minchan Kim , 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" Subject: Re: [PATCH v4] mm: cma: support sysfs Message-ID: References: <20210309062333.3216138-1-minchan@kernel.org> <33ec18ef-8652-643a-1a53-ff7c3caf4399@gmail.com> <78883205-e6da-5bc4-dcec-b6eb921567b1@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <78883205-e6da-5bc4-dcec-b6eb921567b1@gmail.com> X-Stat-Signature: knh4ordwzc13j5yyahs6d8np49uek4ds X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D7D9580194F3 Received-SPF: none (linuxfoundation.org>: No applicable sender policy available) receiver=imf16; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616169047-145543 Content-Transfer-Encoding: quoted-printable 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 Fri, Mar 19, 2021 at 06:38:00PM +0300, Dmitry Osipenko wrote: > 19.03.2021 17:27, Greg Kroah-Hartman =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > > On Fri, Mar 19, 2021 at 05:19:47PM +0300, Dmitry Osipenko wrote: > >> 19.03.2021 16:51, Dmitry Osipenko =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > >>> 19.03.2021 16:47, Greg Kroah-Hartman =D0=BF=D0=B8=D1=88=D0=B5=D1=82= : > >>>> On Fri, Mar 19, 2021 at 04:45:21PM +0300, Dmitry Osipenko wrote: > >>>>> 19.03.2021 16:42, Greg Kroah-Hartman =D0=BF=D0=B8=D1=88=D0=B5=D1=82= : > >>>>>> On Fri, Mar 19, 2021 at 04:39:41PM +0300, Dmitry Osipenko wrote: > >>>>>>> 19.03.2021 15:44, Dmitry Osipenko =D0=BF=D0=B8=D1=88=D0=B5=D1=82= : > >>>>>>> ... > >>>>>>>>> #include > >>>>>>>>> +#include > >>>>>>>>> + > >>>>>>>>> +struct cma_stat { > >>>>>>>>> + spinlock_t lock; > >>>>>>>>> + /* the number of CMA page successful allocations */ > >>>>>>>>> + unsigned long nr_pages_succeeded; > >>>>>>>>> + /* the number of CMA page allocation failures */ > >>>>>>>>> + unsigned long nr_pages_failed; > >>>>>>>>> + struct kobject kobj; > >>>>>>>>> +}; > >>>>>>>>> =20 > >>>>>>>>> struct cma { > >>>>>>>>> unsigned long base_pfn; > >>>>>>>>> @@ -16,6 +26,9 @@ struct cma { > >>>>>>>>> struct debugfs_u32_array dfs_bitmap; > >>>>>>>>> #endif > >>>>>>>>> char name[CMA_MAX_NAME]; > >>>>>>>>> +#ifdef CONFIG_CMA_SYSFS > >>>>>>>>> + struct cma_stat *stat; > >>>>>>>>> +#endif > >>>>>>> > >>>>>>> What is the point of allocating stat dynamically? > >>>>>> > >>>>>> Because static kobjects make me cry. > >>>>>> > >>>>> > >>>>> I meant that it's already a part of struct cma, it looks like the= stat > >>>>> could be embedded into struct cma and then kobj could be initiali= zed > >>>>> separately. > >>>> > >>>> But that structure is statically allocated, so it can not be. Thi= s has > >>>> been discussed in the past threads for when this was reviewed if y= ou are > >>>> curious :) > >>> > >>> Indeed, I missed that cma_areas[] is static, thank you. > >>> > >> > >> And in this case should be better to make only the kobj allocated > >> dynamically instead of the whole cma_stat. > >=20 > > Why does it matter? > >=20 >=20 > Then initialization order won't be a problem. I don't understand the problem here, what is wrong with the patch as-is? Also, watch out, if you only make the kobject dynamic, how are you going to get backwards from the kobject to the values you want to send to userspace in the show functions? thanks, greg k-h