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.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 B3B46C433DB for ; Fri, 5 Feb 2021 05:22:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4DE2964F95 for ; Fri, 5 Feb 2021 05:22:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4DE2964F95 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9E8236B0005; Fri, 5 Feb 2021 00:22:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9977E6B006C; Fri, 5 Feb 2021 00:22:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8AE366B006E; Fri, 5 Feb 2021 00:22:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0193.hostedemail.com [216.40.44.193]) by kanga.kvack.org (Postfix) with ESMTP id 749516B0005 for ; Fri, 5 Feb 2021 00:22:23 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3A6851EFD for ; Fri, 5 Feb 2021 05:22:23 +0000 (UTC) X-FDA: 77783068566.03.dock58_000cc50275e2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 1649328A4E9 for ; Fri, 5 Feb 2021 05:22:23 +0000 (UTC) X-HE-Tag: dock58_000cc50275e2 X-Filterd-Recvd-Size: 4641 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Fri, 5 Feb 2021 05:22:22 +0000 (UTC) Received: by mail-pj1-f50.google.com with SMTP id nm1so3005073pjb.3 for ; Thu, 04 Feb 2021 21:22:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=AA+EJ1DjR2UJlhMyg3jCqq7pLGLJIui+Tm0/F/N50RE=; b=VW4FAjhh23HGT0GktpAHoyl8uJVfA2jFqXTAsfULb123Whqw92I4cM8GYp/LEJ1Hn5 LJWxLATRNupVhw9H+ZW51MkTTNZJ9US75lB9Kr5608XBmwHC/hF6ZjfW+5uEoAH1KPgk bGRcadJ/80CjaKlH39hvSvCYnbmwW4aZpn3BKAQ6FUNfFHkfOiIWB38pLsJPAsawTCw/ M41hOjD3PZVoR5XvaHNNWtR1HfSeAqjdU19G/C7mv+SGaItzk5f7wJ9G+3G1L1Y+A5S3 eFBT+vQli6GaPsHImk+i3hFc/NdkmMzGn+CSgmKEIilqnk+LiG0U/yJBJ9AlLc0IaIOu yikg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=AA+EJ1DjR2UJlhMyg3jCqq7pLGLJIui+Tm0/F/N50RE=; b=Hhe7GOScEWlgDdq/uioPYUlqQl5Yi35WNLtownY/FZYOhVPBYBsIOubvR1jfHn/fa+ CCTUsvNAKvHp4ixPcDVVlSfer8SPlqBMqD7w1PsIJbsxkMOR6koYXjU9iK83YGjpJvA5 SUsDJ9w+e7KSsJA+Vgezoe21dqJ3Dn+KdYl5eBTai641JFD80VJ0Z0g3wFlF2okyPoCb 6prDIwazW/xX4H8GQZlV8OYiyjWs0Cxp5FQJXfKzxAZyfM5EoQe0juge+EToOfyMn7/C V1MokR22BKTbfX28Rrs9oiaFw8LJSEycSM+nN2SVHnd4gmBR/Z4wa7fIW3R5eE/x+EQq NUkA== X-Gm-Message-State: AOAM533+jvpz6UgICSR7+z4X7S4pP997UyBeYdvsOJKxhMN+Fw1p8NqM 3qq5lWhh/mia2+I7fqhYRkGhB7mXCZs= X-Google-Smtp-Source: ABdhPJys67NVmEqSbIl8og6tjRZm9jYGtF8RdQpOly2Vpaii2/8Rd2t/nZrQ31HnhnJfjD+1X7KWaQ== X-Received: by 2002:a17:90b:1b4f:: with SMTP id nv15mr2522992pjb.105.1612502541767; Thu, 04 Feb 2021 21:22:21 -0800 (PST) Received: from google.com ([2620:15c:211:201:598:57c0:5d30:3614]) by smtp.gmail.com with ESMTPSA id x184sm8612789pfb.199.2021.02.04.21.22.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 21:22:20 -0800 (PST) Date: Thu, 4 Feb 2021 21:22:18 -0800 From: Minchan Kim To: Matthew Wilcox Cc: Andrew Morton , gregkh@linuxfoundation.org, surenb@google.com, joaodias@google.com, LKML , linux-mm Subject: Re: [PATCH] mm: cma: support sysfs Message-ID: References: <20210203155001.4121868-1-minchan@kernel.org> <20210205025526.GG308988@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210205025526.GG308988@casper.infradead.org> 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, Feb 05, 2021 at 02:55:26AM +0000, Matthew Wilcox wrote: > 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. OMG. Let me fix it. > > > +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); It's a legacy when I used the lock there but removed finally. Will follow your suggestion. > } > > > + 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? I am not sure what could be in the end but at least, I have 5+ candidates (but could be shrink or extend) and yes, want to keep track them individually.