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 645B5C433E0 for ; Fri, 5 Feb 2021 02:55:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7412364FB7 for ; Fri, 5 Feb 2021 02:55:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7412364FB7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9E2FE6B006C; Thu, 4 Feb 2021 21:55:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B8676B006E; Thu, 4 Feb 2021 21:55:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CFE16B0070; Thu, 4 Feb 2021 21:55:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id 787306B006C for ; Thu, 4 Feb 2021 21:55:44 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4770A180AD801 for ; Fri, 5 Feb 2021 02:55:44 +0000 (UTC) X-FDA: 77782699008.30.D318387 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP id 7B9C3A0000F8 for ; Fri, 5 Feb 2021 02:55:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=sdmQZ0I9b44wVQxMMuojt77Q5ebRbY3Ce9uYruPT/N4=; b=KA+EwLhBnICJ36Bwg8niDsOxTi dB7enbqL+7hyA1T8Mb3gNOQKrBCAtfWlznTLwtZ1+9wE7u90C8PSoE1ihUCzJsi3pvwJ/RdZeZ2iV 1F53YqP5B4x4ejA07mHULC5QRcaaJGZaTSeKdx4VEH/D4qVnBMMdL4dqSPfxBPkr7liBsQvSht+ps JQAaSYAP4AJeAyjyI9C8yq74cuo4NH4gFc+/wLjKljEEFFlusBG44UkDxRmJj4+Fga87vWfJxyKtV h57SNEe3itS0dTeGyZb94slitVJpJ4+kORUaDxrtfrMPcJn54GvjFL/OZL/5Jrd9hkxH1iImIy1VH Afu1cYUg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1l7rHK-001jQP-Jq; Fri, 05 Feb 2021 02:55:29 +0000 Date: Fri, 5 Feb 2021 02:55:26 +0000 From: Matthew Wilcox To: Minchan Kim Cc: Andrew Morton , gregkh@linuxfoundation.org, surenb@google.com, joaodias@google.com, LKML , linux-mm Subject: Re: [PATCH] mm: cma: support sysfs Message-ID: <20210205025526.GG308988@casper.infradead.org> References: <20210203155001.4121868-1-minchan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210203155001.4121868-1-minchan@kernel.org> X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7B9C3A0000F8 X-Stat-Signature: wbcrjrdhhn36q8n19etdnpwy4j8i1h8j Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf07; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1612493741-398018 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 Wed, Feb 03, 2021 at 07:50:01AM -0800, Minchan Kim wrote: > +++ b/mm/Makefile > @@ -106,6 +106,7 @@ obj-$(CONFIG_ZSMALLOC) += zsmalloc.o > obj-$(CONFIG_Z3FOLD) += z3fold.o > obj-$(CONFIG_GENERIC_EARLY_IOREMAP) += early_ioremap.o > obj-$(CONFIG_CMA) += cma.o > +obj-$(CONFIG_SYSFS) += cma_sysfs.o ehh ... if we have a kernel build with CMA=n, SYSFS=y, we'll get cma_sysfs built in with no cma to report on. > +static ssize_t cma_alloc_attempt_show(struct kobject *kobj, > + struct kobj_attribute *attr, char *buf) > +{ > + unsigned long val; > + struct cma_stat *stat = container_of(kobj, struct cma_stat, kobj); > + > + val = stat->alloc_attempt; > + > + return sysfs_emit(buf, "%lu\n", val); Why not more simply: { struct cma_stat *stat = container_of(kobj, struct cma_stat, kobj); return sysfs_emit(buf, "%lu\n", stat->alloc_attempt); } > + for (i = 0; i < cma_area_count; i++) { > + cma = &cma_areas[i]; > + stat = kzalloc(sizeof(*stat), GFP_KERNEL); > + if (!stat) > + goto out; How many cma areas are there going to be? do we really want to allocate their stat individually?