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=-11.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 8892DC433C1 for ; Fri, 19 Mar 2021 15:13:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 484E16192F for ; Fri, 19 Mar 2021 15:13:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230060AbhCSPM1 (ORCPT ); Fri, 19 Mar 2021 11:12:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:46420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230049AbhCSPMM (ORCPT ); Fri, 19 Mar 2021 11:12:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D5CB461920; Fri, 19 Mar 2021 15:12:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616166732; bh=uHqXLPYIm+oaU9HFxAoPyIBK42c9sp7ydb4Y3G+Jt1s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KILv1fOLj5Cfx38p4iiKW+7gU2e/vf9Ez0srm1r7Hhok6kyR4FRmrxji3i/+8nBee BNASI2T1YacQ4GbAYiTelsH4+bpEUpf6zEibX9Dhxqd6kFvntbqmk8mtVGYunxZYj1 Yez6iemcqjUQ4pDcNmNDTTjf6rvxNL/8oezo2XLw= Date: Fri, 19 Mar 2021 15:27:52 +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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org On Fri, Mar 19, 2021 at 05:19:47PM +0300, Dmitry Osipenko wrote: > 19.03.2021 16:51, Dmitry Osipenko пишет: > > 19.03.2021 16:47, Greg Kroah-Hartman пишет: > >> On Fri, Mar 19, 2021 at 04:45:21PM +0300, Dmitry Osipenko wrote: > >>> 19.03.2021 16:42, Greg Kroah-Hartman пишет: > >>>> On Fri, Mar 19, 2021 at 04:39:41PM +0300, Dmitry Osipenko wrote: > >>>>> 19.03.2021 15:44, Dmitry Osipenko пишет: > >>>>> ... > >>>>>>> #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; > >>>>>>> +}; > >>>>>>> > >>>>>>> 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 initialized > >>> separately. > >> > >> But that structure is statically allocated, so it can not be. This has > >> been discussed in the past threads for when this was reviewed if you 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. Why does it matter?