Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1510836pxf; Fri, 19 Mar 2021 08:40:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2pOiHMrB3n5LMG0tSmFZ39GnknjIReAyrs0kfg3Sa2O0lU9i+6EzQGU5Um+m+bkRjHvoy X-Received: by 2002:aa7:d0d7:: with SMTP id u23mr10097659edo.255.1616168414855; Fri, 19 Mar 2021 08:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616168414; cv=none; d=google.com; s=arc-20160816; b=ZpyJWbb9l1ESIQig/IY0WWCTLyaI7s2j4PJKXThysg43ywCDDQ7RI40tq8TDKKyvAA HaeQXtYq5LtX/4WR0z0tje91KE/KEOMAf7a0XrVqTNGsFVUcCnuVU7QokyMPMKIbmzQG FxzxXRUA8eQJXNsUucj/KbfqXaAb7pMzmj+DHwA9kczWY+eEirTXahVhiGr+7+oSYBOC gDDxw5gLo+abIK3g7PV4KkVQuHtKdp/AjtfwJEuSxCCLfoC7ldZoQpNhgNXC9pKXrG8F ty+jxzJ/d045wg1FXWXASBDBmvLqABZPYMPbTyDGoMpi4gxbYUJ9Fn0MVdU4DAP71INT C0KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=Jf57TUyTvZSa9yhzASEEIFzKPdOCKjXIr1XoPSFG8S4=; b=d8jEOBup7Wr1JoFxNpHh1n9V5Nds7j0wMXL6rA422ch3uDhO2fH9wO+tZ7EVHuH16n oYJ9bGIDC2JwrbMVApOwRcUVNWfDAsGhSnHPECDwqGYPuOQjOXh6fHvdp1RY6ikYcOY1 gjFEVoZY19u11c0/5BE974P8Ksq7ytv4Zf+AuaCSx/pNRik0uY/gXxk+H3Ifm8t0Noaf PM5el7gUqdj8x5PJhppTm8MIKi+hTjY0GkhVyseDFoYQXHsnmdpn34W3S7H16+tbXScE q8my90gKhB6cmMvQb9ka0xG1eo908dOP94q9Hy/IQvXFwc8PJ0rGYdicl1LRgp904FjE vsGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QRAIefYI; 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=QUARANTINE dis=NONE) header.from=gmail.com 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.39.51; Fri, 19 Mar 2021 08:40:14 -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=@gmail.com header.s=20161025 header.b=QRAIefYI; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230259AbhCSPiX (ORCPT + 99 others); Fri, 19 Mar 2021 11:38:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230002AbhCSPiD (ORCPT ); Fri, 19 Mar 2021 11:38:03 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4184DC06174A; Fri, 19 Mar 2021 08:38:03 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id s17so12519225ljc.5; Fri, 19 Mar 2021 08:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Jf57TUyTvZSa9yhzASEEIFzKPdOCKjXIr1XoPSFG8S4=; b=QRAIefYIOEXTF4OXlTA0vcyHwbml1t5N2cCxy7cInDOWHksDc5nCuyl9EO/CPG9BvV iwlvhSxYy6znZBNlSID/YT0AGej5231j3erF2uZHDfDTMkZCT8m3OaV/Z/caoaKIJ2Fs 0blij0eTp3zxv1sN5e+bJavnO6P35HOf07XFC9fx6xTjNGQisIX1vQT/6PvlPcB3k8lB waSCCJTyTOVVMQFNkIKTtu44Gqr4XSy6sYow5tjL4hfzV4Owu0ZDqWwUU5JzSzmWiWGJ r5/l/OKtz9Xb5ctLArl7ay+tWcUsOlPNNynK+RZmpOktiSyBoH6N6dHmNQY/edXZshSp fuLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Jf57TUyTvZSa9yhzASEEIFzKPdOCKjXIr1XoPSFG8S4=; b=salDvCPiWh7vEty5AecsYO3lcWC8ga9c4sMl+C1HGLnQX5jJ281sVtMnxgQ8DqgXPh II3A36A+/Qt7v1rokoj1Ihr3vUiHzBv9xZSgGb5NpG25+xUf3z3jO1GyplrDyjGjeSLZ rFlCUp1k/4hAZ+98hPpis9IqfsT820q8M+M3mzFOu5qMEOQgzBo87d8B1SvQhLd4Fa9t faaWsyWi3GafLJG+oNBtrNJJo81aGFzBQRHUtUJATqAxr/ejK5yuI0tKRxiTP1nedcjL S3kVcmpde9nH8DVH4dcIuTKj7pC1TmQJsIwdPRKoBaCq0cSw60sRuLva5ysgfKPi9fsV 6yqA== X-Gm-Message-State: AOAM530y7bt+M8oZbMev7mf2HhJ6qyY+tSs+ym1+f8PA9LFXPaz62CBb zrkqf4lIbvf2QOoDa3mKXve126kV21o= X-Received: by 2002:a2e:b60d:: with SMTP id r13mr1310809ljn.30.1616168281607; Fri, 19 Mar 2021 08:38:01 -0700 (PDT) Received: from [192.168.2.145] (109-252-193-52.dynamic.spd-mgts.ru. [109.252.193.52]) by smtp.googlemail.com with ESMTPSA id f25sm662396lfh.226.2021.03.19.08.38.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Mar 2021 08:38:00 -0700 (PDT) Subject: Re: [PATCH v4] mm: cma: support sysfs To: Greg Kroah-Hartman 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" References: <20210309062333.3216138-1-minchan@kernel.org> <33ec18ef-8652-643a-1a53-ff7c3caf4399@gmail.com> From: Dmitry Osipenko Message-ID: <78883205-e6da-5bc4-dcec-b6eb921567b1@gmail.com> Date: Fri, 19 Mar 2021 18:38:00 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.