Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1591561pxb; Thu, 4 Feb 2021 17:53:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJyIqjegQNbB9x5jmXyPxJNJ/ud/H3m4o1lOPJz7qZZO6+4wPKyhEkKWAER2VNFyKfN6NOWh X-Received: by 2002:a05:6402:3494:: with SMTP id v20mr1401840edc.146.1612490012343; Thu, 04 Feb 2021 17:53:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612490012; cv=none; d=google.com; s=arc-20160816; b=UVUGLKk9AoHEv3PQF6Ls8LIjVKzP0/gSnSqZPi9WaT7hqGjdKuEvaujF70QySmXOHM ABIBnldl34mQGn0OPveS/h7BJx1qmzXf4D7KsmxxmbatFxMtV8VxtyUsPOqiny6zIk9/ sgX6nKl+13jn7rIaDgSyc+qAaVJH4ZYGjYVxClYalveAGwaElAC+3Mnb6XrTCMttgy0u U/oJLTLgJfGp4QX1c/FHFe9ao77N/33BIPBitv9ItsaInF/vCSKFUKdOOwrD7qidbAf1 LvQHYiZriEY39nm6/9M9umWdyrRTkisAH3zmlb8NNyRoPKGlB8jLORmTjtfJCw8ni2lJ aFnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=QdxivZtYPm/w27qYlDAWfOEEAK/f2pjTA4/stH/yMGY=; b=r6twaEhAkLXMDX1/kD9zhJKjxvAdOLMkzeuMoiush7rWKNB4x7SUySIYOzvGYHb3W0 vuSWQ75iQInepVeIAwMBPG5DmuWMVtgZpk9vUYhbtMIjjuqTJPkU8mN4LngG85xApJwH 7uGWnh4/DGIgOYhDMoNRSfUgjnB9gId7np0q4NnslwhgNL7KS0sw1Nib1jGiNL5t2/9u uosQc74oC4G/Gz1r7OhfdDzBb59vZ3RlutLzg+j2qwmHNpz2/ph4vMgDAVlPsYS1ReOL oFwZufBdNQEUseBhEoIuaKU3MXZpi3+2CJrq9mvl0wrMZGO5RsklwzDeCidYt8Qj/qqF I0EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JVcDR5Fa; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x22si4258934ejv.202.2021.02.04.17.53.07; Thu, 04 Feb 2021 17:53:32 -0800 (PST) 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=@google.com header.s=20161025 header.b=JVcDR5Fa; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231233AbhBDXoW (ORCPT + 99 others); Thu, 4 Feb 2021 18:44:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231228AbhBDXoK (ORCPT ); Thu, 4 Feb 2021 18:44:10 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 775D9C06178B for ; Thu, 4 Feb 2021 15:43:23 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id j11so4562979wmi.3 for ; Thu, 04 Feb 2021 15:43:23 -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=QdxivZtYPm/w27qYlDAWfOEEAK/f2pjTA4/stH/yMGY=; b=JVcDR5FaBcM/8aHWqzBqRX9vTW+ZRxzi1CD3sesrMKWoJInMMvK5ATZXuu1H1O7jgi Xt4HFN4ew7WWWGgd85IxBQCSgFeXmetfJiiWWsyxlHFxINjmmw8elzZu54u//MEjcH/z QMSlcsi1GfzSjKTOOOifAtWzF2MAeYxxjGMZVAvVV3TPPumO9/YXl8F3//UbVp6dmvoz XMfsGfvmTgUOTzn0DLa5BCjWdHpG76fQmQRoUZIavXMuwC+UnKl96rgRcVbpSieaFobz W7HzqeBjEDInkEaC//hRLUH2jOgubIV9oetGMZM0Va29gTt9QdQQjVPUJ9QwWr1XtesS KHyQ== 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=QdxivZtYPm/w27qYlDAWfOEEAK/f2pjTA4/stH/yMGY=; b=TYo6d805Gz4nmx78cSGYtpCNN2nRoSjILLQ0xihvcoe+JqX4vnfkNwcwzVIukXMlx7 ze+96Dci9W2XvKwtiKUzFAmjCNw7jEWSwPFbj/KvqzgoLNOf7QRwjMMV5LTaEFfIidcT GuhDkaMbhFNhOVOxcuYX0n8Va2pM0rHgFz4D/HabqeMz6oEU1NLXpn7gLEyiSNLxdg7+ HTsV6xsyhPwYLF3yMLemusLaDIoMqtWgHWVuXmIuNKPZkJed0LKnAK81gKTJKpboDOtq lOeLkltC8sQL2wh8k0zfN2hpOt0+T5U8W39sDtNaudz6cCC/RA5Icrj2SInmier+7nlb 8AMg== X-Gm-Message-State: AOAM532MyKBGGWx6KGGLzA+OTX8EbRtONF1ydMIPBjqRN4wVNR66w4eW PwRK/sJ/s6X20a3wI+wds/KbxxrGMHnk+5t4xQqMvg== X-Received: by 2002:a05:600c:4f93:: with SMTP id n19mr1169835wmq.163.1612482201973; Thu, 04 Feb 2021 15:43:21 -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:43:10 -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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > > 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. > > >