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=-17.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 6B945C433DB for ; Wed, 17 Feb 2021 20:57:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1494164E45 for ; Wed, 17 Feb 2021 20:57:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1494164E45 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id ACE178D0001; Wed, 17 Feb 2021 15:57:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A7DF46B0071; Wed, 17 Feb 2021 15:57:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99F8F6B006E; Wed, 17 Feb 2021 15:57:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0061.hostedemail.com [216.40.44.61]) by kanga.kvack.org (Postfix) with ESMTP id 837B06B006E for ; Wed, 17 Feb 2021 15:57:28 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 46A37BF15 for ; Wed, 17 Feb 2021 20:57:28 +0000 (UTC) X-FDA: 77828970576.12.curve81_02045302764f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 2B32B181C02AF for ; Wed, 17 Feb 2021 20:57:28 +0000 (UTC) X-HE-Tag: curve81_02045302764f X-Filterd-Recvd-Size: 5508 Received: from hqnvemgate24.nvidia.com (hqnvemgate24.nvidia.com [216.228.121.143]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Wed, 17 Feb 2021 20:57:27 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Wed, 17 Feb 2021 12:57:26 -0800 Received: from [10.2.55.242] (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 17 Feb 2021 20:57:25 +0000 Subject: Re: [PATCH] mm: vmstat: add cma statistics To: Minchan Kim , Andrew Morton CC: linux-mm , LKML , , References: <20210217170025.512704-1-minchan@kernel.org> From: John Hubbard Message-ID: <8036d8e6-8e96-7b4e-91c0-e1ae91b637e1@nvidia.com> Date: Wed, 17 Feb 2021 12:57:25 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:85.0) Gecko/20100101 Thunderbird/85.0 MIME-Version: 1.0 In-Reply-To: <20210217170025.512704-1-minchan@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1613595446; bh=hI0hY92PVZ/Q8bLOHZtIMPTuj0DO35pgrbP+g6IycJk=; h=Subject:To:CC:References:From:Message-ID:Date:User-Agent: MIME-Version:In-Reply-To:Content-Type:Content-Language: Content-Transfer-Encoding:X-Originating-IP:X-ClientProxiedBy; b=f31UQ+734TU3Iut9TEFTyDhQ6PvmWIYjezGcPbIORNJCP39NI5Fph5I0kpRe72Bf/ UpKtyfwXEnAvDY+pv8butvZABcj2ACipE2xPBQwWFmCzx9DVMTh8fi1HhmbJIQfAsk aeID8fnSAY7VLGN8ss7vxX/3x2y8nVKDn4ncGhBBC4U15nioCJar9pSCLl42rjSGNu uh+xo9BsXK2wphoepTQyYnfDWznq6+AlXYD/dJwtGdswsQtXrO8IqcfB8Apxfb3xTY Op0ply0O2UbEbYCnP9gHV+5uiaAt4xn0n5xU160AnUoUyGBTG0nSCeztKkerncRmBu 1npqpwcE9puZQ== 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 2/17/21 9:00 AM, Minchan Kim wrote: > Since CMA is used more widely, it's worth to have CMA > allocation statistics into vmstat. With it, we could > know how agressively system uses cma allocation and > how often it fails. > > Signed-off-by: Minchan Kim > --- > include/linux/vm_event_item.h | 3 +++ > mm/cma.c | 12 +++++++++--- > mm/vmstat.c | 4 ++++ > 3 files changed, 16 insertions(+), 3 deletions(-) > > diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h > index 18e75974d4e3..0c567014ce82 100644 > --- a/include/linux/vm_event_item.h > +++ b/include/linux/vm_event_item.h > @@ -70,6 +70,9 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, > #endif > #ifdef CONFIG_HUGETLB_PAGE > HTLB_BUDDY_PGALLOC, HTLB_BUDDY_PGALLOC_FAIL, > +#endif > +#ifdef CONFIG_CMA > + CMA_ALLOC, CMA_ALLOC_FAIL, This seems wrong: here it's called "alloc", but in the output it's called "alloc success", and in the implementation it's clearly "alloc attempt" that is being counted. Once these are all made consistent, then the bug should naturally go away as part of that. nit: I think the multiple items per line is a weak idea at best, even though it's used here already. Each item is important and needs to be visually compared to it's output item later. So one per line might have helped avoid mismatches, and I think we should change to that to encourage that trend. thanks, -- John Hubbard NVIDIA > #endif > UNEVICTABLE_PGCULLED, /* culled to noreclaim list */ > UNEVICTABLE_PGSCANNED, /* scanned for reclaimability */ > diff --git a/mm/cma.c b/mm/cma.c > index 23d4a97c834a..ea1e39559526 100644 > --- a/mm/cma.c > +++ b/mm/cma.c > @@ -434,14 +434,16 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, > struct page *page = NULL; > int ret = -ENOMEM; > > + count_vm_event(CMA_ALLOC); > + > if (!cma || !cma->count || !cma->bitmap) > - return NULL; > + goto out; > > pr_debug("%s(cma %p, count %zu, align %d)\n", __func__, (void *)cma, > count, align); > > if (!count) > - return NULL; > + goto out; > > mask = cma_bitmap_aligned_mask(cma, align); > offset = cma_bitmap_aligned_offset(cma, align); > @@ -449,7 +451,7 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, > bitmap_count = cma_bitmap_pages_to_bits(cma, count); > > if (bitmap_count > bitmap_maxno) > - return NULL; > + goto out; > > for (;;) { > mutex_lock(&cma->lock); > @@ -506,6 +508,10 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, > } > > pr_debug("%s(): returned %p\n", __func__, page); > +out: > + if (!page) > + count_vm_event(CMA_ALLOC_FAIL); > + > return page; > } > > diff --git a/mm/vmstat.c b/mm/vmstat.c > index 97fc32a53320..d8c32a33208d 100644 > --- a/mm/vmstat.c > +++ b/mm/vmstat.c > @@ -1305,6 +1305,10 @@ const char * const vmstat_text[] = { > #ifdef CONFIG_HUGETLB_PAGE > "htlb_buddy_alloc_success", > "htlb_buddy_alloc_fail", > +#endif > +#ifdef CONFIG_CMA > + "cma_alloc_success", > + "cma_alloc_fail", > #endif > "unevictable_pgs_culled", > "unevictable_pgs_scanned", >