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=-23.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 20D21C433E0 for ; Thu, 4 Feb 2021 23:46:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B7ED764FA4 for ; Thu, 4 Feb 2021 23:46:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7ED764FA4 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0FDE06B0006; Thu, 4 Feb 2021 18:46:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B1336B006C; Thu, 4 Feb 2021 18:46:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F2ED56B006E; Thu, 4 Feb 2021 18:46:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0002.hostedemail.com [216.40.44.2]) by kanga.kvack.org (Postfix) with ESMTP id DD8AC6B0006 for ; Thu, 4 Feb 2021 18:46:11 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id AD750362A for ; Thu, 4 Feb 2021 23:46:11 +0000 (UTC) X-FDA: 77782221342.10.art04_3b073e2275e0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 9378516A0DE for ; Thu, 4 Feb 2021 23:46:11 +0000 (UTC) X-HE-Tag: art04_3b073e2275e0 X-Filterd-Recvd-Size: 10480 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Feb 2021 23:46:11 +0000 (UTC) Received: by mail-wr1-f51.google.com with SMTP id v15so5616777wrx.4 for ; Thu, 04 Feb 2021 15:46:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bTFYacgr3f2BQvj6aolTtHouKG7szuoe8gy8cxFyffc=; b=rSX7T+fOlYs+bfzwr2IkddtBAES+QPf8GZVPHckaPpg2E8tnGcRGEuyDK47KNqHovP XXMmPUqjMfjmUlmLUFImKa66/QltUVEhEM/DvTxIdxc/rZ2wE5MJddKovbidEWFmnlYL Am5M6TWK//G4j61E6SsaQYVo+g4YvlM68DPt8+t3g9hzrBjPAKfal/K5qRNJeLRg2Ytz B/niP9PEW3o4nI5IGJBf+t9MrqvnfcMhrnuGHZlF+TlQSYuYEDeXWoXnVjjIOo8mnt/o qpB+2znzVsTuDuGDpX/zUWMdYvjP3fhfRqhMbM4vcI4j7Db/hpKJFIaVQiQ3UD+1vCAK N8iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bTFYacgr3f2BQvj6aolTtHouKG7szuoe8gy8cxFyffc=; b=ijg8KT0Zmz2A7I3VmCuD0eWb6GVzXbuQF0kUhpUx9Rx4Kyy9to7MOsw8ZtN+vQrH6k LYapNfheqr1CbuAPqna62cdtUzB63G6ge2NMRZUf7puRctQMDr/79A19umi+JFnBxfPp 8utMVfrTqMROupCIORr2hkSFR81rMjLGDnK1P69E7i6qfYrMAudABypJjfE/ITwhAUQB /HunKPfF/RX5EZXwc32f3RBgI6P+nHGmgvuFNF95rUFhwa+ZoD4sOrsVm6e3P0tXVJsC S46Mmm1jyk9u+ilsHhIga5d0wHNlJMLl6LXK2osC9TzgsLQVcLYf0nTkPsyGWjoxAhMb wWPA== X-Gm-Message-State: AOAM530Oj704hENosrTaDiP1yzJeEWz6x85Ponq9KrRJdxFMBlMI+YCb AHQnpyXcWdo/pXDFU/eClUtguYH0eEgHON/kCjipQA== X-Google-Smtp-Source: ABdhPJzpAuy109DfqhaZieLgcRciXXZcvwNfYebICSt7Y1i/Pc1Z2EcQ2b6s83mnIphiDmauPWCE/Rw6uT4Ohe/a8XE= X-Received: by 2002:adf:ed45:: with SMTP id u5mr1813684wro.358.1612482369805; Thu, 04 Feb 2021 15:46:09 -0800 (PST) MIME-Version: 1.0 References: <20210203155001.4121868-1-minchan@kernel.org> <7e7c01a7-27fe-00a3-f67f-8bcf9ef3eae9@nvidia.com> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 4 Feb 2021 15:45:58 -0800 Message-ID: Subject: Re: [PATCH] mm: cma: support sysfs To: John Hubbard Cc: Minchan Kim , Andrew Morton , Greg Kroah-Hartman , John Dias , LKML , linux-mm Content-Type: text/plain; charset="UTF-8" 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 Thu, Feb 4, 2021 at 3:43 PM Suren Baghdasaryan wrote: > > On Thu, Feb 4, 2021 at 3:14 PM John Hubbard wrote: > > > > On 2/4/21 12:07 PM, Minchan Kim wrote: > > > On Thu, Feb 04, 2021 at 12:50:58AM -0800, John Hubbard wrote: > > >> On 2/3/21 7:50 AM, Minchan Kim wrote: > > >>> Since CMA is getting used more widely, it's more important to > > >>> keep monitoring CMA statistics for system health since it's > > >>> directly related to user experience. > > >>> > > >>> This patch introduces sysfs for the CMA and exposes stats below > > >>> to keep monitor for telemetric in the system. > > >>> > > >>> * the number of CMA allocation attempts > > >>> * the number of CMA allocation failures > > >>> * the number of CMA page allocation attempts > > >>> * the number of CMA page allocation failures > > >> > > >> The desire to report CMA data is understandable, but there are a few > > >> odd things here: > > >> > > >> 1) First of all, this has significant overlap with /sys/kernel/debug/cma > > >> items. I suspect that all of these items could instead go into > > > > > > At this moment, I don't see any overlap with item from cma_debugfs. > > > Could you specify what item you are mentioning? > > > > Just the fact that there would be two systems under /sys, both of which are > > doing very very similar things: providing information that is intended to > > help diagnose CMA. > > > > > > > >> /sys/kernel/debug/cma, right? > > > > > > Anyway, thing is I need an stable interface for that and need to use > > > it in Android production build, too(Unfortunately, Android deprecated > > > the debugfs > > > https://source.android.com/setup/start/android-11-release#debugfs > > > ) > > > > That's the closest hint to a "why this is needed" that we've seen yet. > > But it's only a hint. > > > > > > > > What should be in debugfs and in sysfs? What's the criteria? > > > > Well, it's a gray area. "Debugging support" goes into debugfs, and > > "production-level monitoring and control" goes into sysfs, roughly > > speaking. And here you have items that could be classified as either. > > > > > > > > Some statistic could be considered about debugging aid or telemetric > > > depening on view point and usecase. And here, I want to use it for > > > telemetric, get an stable interface and use it in production build > > > of Android. In this chance, I'd like to get concrete guideline > > > what should be in sysfs and debugfs so that pointing out this thread > > > whenever folks dump their stat into sysfs to avoid waste of time > > > for others in future. :) > > > > > >> > > >> 2) The overall CMA allocation attempts/failures (first two items above) seem > > >> an odd pair of things to track. Maybe that is what was easy to track, but I'd > > >> vote for just omitting them. > > > > > > Then, how to know how often CMA API failed? > > > > Why would you even need to know that, *in addition* to knowing specific > > page allocation numbers that failed? Again, there is no real-world motivation > > cited yet, just "this is good data". Need more stories and support here. > > IMHO it would be very useful to see whether there are multiple > small-order allocation failures or a few large-order ones, especially > for CMA where large allocations are not unusual. For that I believe > both alloc_pages_attempt and alloc_pages_fail would be required. Sorry, I meant to say "both cma_alloc_fail and alloc_pages_fail would be required". > > > > > > > thanks, > > -- > > John Hubbard > > NVIDIA > > > > > There are various size allocation request for a CMA so only page > > > allocation stat are not enough to know it. > > > > > >>> > > >>> Signed-off-by: Minchan Kim > > >>> --- > > >>> Documentation/ABI/testing/sysfs-kernel-mm-cma | 39 +++++ > > >>> include/linux/cma.h | 1 + > > >>> mm/Makefile | 1 + > > >>> mm/cma.c | 6 +- > > >>> mm/cma.h | 20 +++ > > >>> mm/cma_sysfs.c | 143 ++++++++++++++++++ > > >>> 6 files changed, 209 insertions(+), 1 deletion(-) > > >>> create mode 100644 Documentation/ABI/testing/sysfs-kernel-mm-cma > > >>> create mode 100644 mm/cma_sysfs.c > > >>> > > >>> diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-cma b/Documentation/ABI/testing/sysfs-kernel-mm-cma > > >>> new file mode 100644 > > >>> index 000000000000..2a43c0aacc39 > > >>> --- /dev/null > > >>> +++ b/Documentation/ABI/testing/sysfs-kernel-mm-cma > > >>> @@ -0,0 +1,39 @@ > > >>> +What: /sys/kernel/mm/cma/ > > >>> +Date: Feb 2021 > > >>> +Contact: Minchan Kim > > >>> +Description: > > >>> + /sys/kernel/mm/cma/ contains a number of subdirectories by > > >>> + cma-heap name. The subdirectory contains a number of files > > >>> + to represent cma allocation statistics. > > >> > > >> Somewhere, maybe here, there should be a mention of the closely related > > >> /sys/kernel/debug/cma files. > > >> > > >>> + > > >>> + There are number of files under > > >>> + /sys/kernel/mm/cma/ directory > > >>> + > > >>> + - cma_alloc_attempt > > >>> + - cma_alloc_fail > > >> > > >> Are these really useful? They a summary of the alloc_pages items, really. > > >> > > >>> + - alloc_pages_attempt > > >>> + - alloc_pages_fail > > >> > > >> This should also have "cma" in the name, really: cma_alloc_pages_*. > > > > > > No problem. > > > > > >> > > >>> + > > >>> +What: /sys/kernel/mm/cma//cma_alloc_attempt > > >>> +Date: Feb 2021 > > >>> +Contact: Minchan Kim > > >>> +Description: > > >>> + the number of cma_alloc API attempted > > >>> + > > >>> +What: /sys/kernel/mm/cma//cma_alloc_fail > > >>> +Date: Feb 2021 > > >>> +Contact: Minchan Kim > > >>> +Description: > > >>> + the number of CMA_alloc API failed > > >>> + > > >>> +What: /sys/kernel/mm/cma//alloc_pages_attempt > > >>> +Date: Feb 2021 > > >>> +Contact: Minchan Kim > > >>> +Description: > > >>> + the number of pages CMA API tried to allocate > > >>> + > > >>> +What: /sys/kernel/mm/cma//alloc_pages_fail > > >>> +Date: Feb 2021 > > >>> +Contact: Minchan Kim > > >>> +Description: > > >>> + the number of pages CMA API failed to allocate > > >>> diff --git a/include/linux/cma.h b/include/linux/cma.h > > >>> index 217999c8a762..71a28a5bb54e 100644 > > >>> --- a/include/linux/cma.h > > >>> +++ b/include/linux/cma.h > > >>> @@ -49,4 +49,5 @@ extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, > > >>> extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count); > > >>> extern int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data); > > >>> + > > >> > > >> A single additional blank line seems to be the only change to this file. :) > > > > > > Oops. > > > > >