Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1519512pxf; Fri, 19 Mar 2021 08:52:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZRKI/wc9yJRCwR94/P+9yTCCloYm3Oldxc3gwP5207zUvoxdGUUrTn3PYS3Ykkd6R+vUo X-Received: by 2002:a05:6402:278b:: with SMTP id b11mr10408630ede.380.1616169144023; Fri, 19 Mar 2021 08:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616169144; cv=none; d=google.com; s=arc-20160816; b=RgucU1uncUpxxVnKfetkeJP+HLajXw3zZOlvD5+zUXymrDQccMZiLqOyBd5nYz8JmI szSEKF6zg7K9/ywlSUPM8sM4SnEnwpz1G6R0JawhC7rcnpr6TcjRZkTZv0/7iX21NRqq lJw0YVWuBcr4mSWTmhYKI8nAWlxMEE8A0xwd5IMQKJIPAcecmKzJuuVYG9vvpctFr4NS bibS5NW7phjZHnB8petLIU50E8YLRgWjeOIc6Vc2oQOqpmVfYa6CGStLhXwXs3OG4LRQ 7x3UoIdieZm1518w6q9TACv8X5CWBim3TILLq4O7X0YOz+IF7gT8HOaYW+1saBsT9uh9 9rfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=0wLTev+iudR4nnEIrH1ysJEOtcHBSIwiJOj69P+bUG0=; b=tFcg3NTdzuUlj5AVZrfCQtfkgYBfEeNhGAPHiQwfUdjpzURciSFs2EAHvaNkvlpUk2 414M2PAtRuhgdevwiTFVuw/pBQAWUBRhduaCOJ6sdXcZKvdQgJXaEPYn3gJAAl3HRyyf Fl0S9pQMf4/H2at85usGQYK3LWGnldMQ+ekSE58KMU8FiIU21Kwk4Jjd+1vxFCRr5UJQ /B4y3vEKWXl1S5uLEYz+i92sKiky2r+b+9/KtWuuUYdWyZQ3t103HK/zsIx85blMqrM2 /T9Mt1fdkoHxsGlK5swkND4DxRmfDxeQaKAkWSxatgPtteBEtkLM9nXs7rTabGCLlxiu QZ0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qBKpkhyX; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j22si4362847edq.584.2021.03.19.08.52.00; Fri, 19 Mar 2021 08:52:24 -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=@linuxfoundation.org header.s=korg header.b=qBKpkhyX; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230063AbhCSPvD (ORCPT + 99 others); Fri, 19 Mar 2021 11:51:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:56050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229893AbhCSPum (ORCPT ); Fri, 19 Mar 2021 11:50:42 -0400 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 Content-Transfer-Encoding: 8bit In-Reply-To: <78883205-e6da-5bc4-dcec-b6eb921567b1@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 19, 2021 at 06:38:00PM +0300, Dmitry Osipenko wrote: > 19.03.2021 17:27, Greg Kroah-Hartman пишет: > > 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? > > > > 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