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=-13.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,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 5C28CC433C1 for ; Mon, 29 Mar 2021 20:12:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E3A716192F for ; Mon, 29 Mar 2021 20:12:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3A716192F 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 6F8E26B007D; Mon, 29 Mar 2021 16:12:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A9516B007E; Mon, 29 Mar 2021 16:12:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5223E6B0080; Mon, 29 Mar 2021 16:12:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0133.hostedemail.com [216.40.44.133]) by kanga.kvack.org (Postfix) with ESMTP id 363296B007D for ; Mon, 29 Mar 2021 16:12:47 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E43458249980 for ; Mon, 29 Mar 2021 20:12:46 +0000 (UTC) X-FDA: 77974009932.07.9BD2B86 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf21.hostedemail.com (Postfix) with ESMTP id 5F89CE0011E1 for ; Mon, 29 Mar 2021 20:12:35 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id cl21-20020a17090af695b02900c61ac0f0e9so115590pjb.1 for ; Mon, 29 Mar 2021 13:12:36 -0700 (PDT) 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=Y+d/t03e3sX/iKjO1lc3uXhJRbYL34/AivFkYivWjD0=; b=HshjOCJr5Nhl19R9/SbR4nvIN+du4ihSRWbmtyKExkp0BkXMjUCzl2agZOl1LNvNDu RD6DzMgQOINdIe1V2h5v7Mbe9FnPkGJXqy59wF08o5XK5x+7HO/0P620fIMgbEzzup/n vmV+dFNALYDkZDNtWAtOICskIWvsdtXKb635nTmERHd/Qkd8HTA1JKvrcLaqRJfk2ZMS BsNm5ZIF2IyOEJXKx6lpvUSVr+3aOwfMm81qPvmvwFZstMd1OJAKyY67Zmwz7QEmX8Bl T50PlELaXbvbhK170wyKt6wkfZ0GAnh47lHNxNv1VCGDiv1apVF5D1Xsv/EZ7gU/NQM7 7T5g== 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=Y+d/t03e3sX/iKjO1lc3uXhJRbYL34/AivFkYivWjD0=; b=Sm8L24K3OqxU3K/It3tWTEEiheFGNlTdej4MbKozSnUUjpB4oW1F3Dq1n/FvZ683UN 93jLKEtPdIzAIhpSKjspcKKen/gF4iEiOWkxq1HCFc2MqNgU+vXbUbB3mrQ0kwSvBE75 J+b4CaNKLpWue0Qkv4gm4zAheQGkVLeQANXx6iudKhaa0f5/boh9uTU4oecJrfj7DVof MjnkkbC3Vc7gXECCNDkFKu4xpbED2XSrAO7JAXb7Z0ylWuMX82tULuKYE/K6XgBPRbds vn6dnuz/O7uvIaa7PSPNWVKHGqSRptDMnLNPQsK9ixbgip5zhwJJBkEsO9Jd/mDaww1S /ghg== X-Gm-Message-State: AOAM533EdL2KMB7t8Hl0anQoAWj48lzEcu0zDLb2qTIrJgU8zMILUd8d J/Kcxq+gz6HgeQvBbRpwyvA= X-Google-Smtp-Source: ABdhPJw2cBwLPRh/lll28/QMNz/rXZkFuhxx8d9Xu4lKgmYRWKaiR9X8DYk3s6nMn6YvzoRnDNxc2w== X-Received: by 2002:a17:90a:bb8b:: with SMTP id v11mr833995pjr.4.1617048755762; Mon, 29 Mar 2021 13:12:35 -0700 (PDT) Received: from google.com ([2620:15c:211:201:e9af:f14a:516c:eaef]) by smtp.gmail.com with ESMTPSA id p25sm18257708pfe.100.2021.03.29.13.12.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 13:12:34 -0700 (PDT) Date: Mon, 29 Mar 2021 13:12:33 -0700 From: Minchan Kim To: Matthew Wilcox Cc: Andrew Morton , linux-mm , LKML , david@redhat.com Subject: Re: [PATCH] mm: change size_t to unsigned int for cma_alloc Message-ID: References: <20210329182553.3129234-1-minchan@kernel.org> <20210329184431.GJ351017@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210329184431.GJ351017@casper.infradead.org> X-Rspamd-Queue-Id: 5F89CE0011E1 X-Stat-Signature: uhz3pis57nmxb17g4rffq6z36zrmub3n X-Rspamd-Server: rspam02 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf21; identity=mailfrom; envelope-from=""; helo=mail-pj1-f43.google.com; client-ip=209.85.216.43 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617048755-539862 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 Mon, Mar 29, 2021 at 07:44:31PM +0100, Matthew Wilcox wrote: > On Mon, Mar 29, 2021 at 11:25:53AM -0700, Minchan Kim wrote: > > size_t in cma_alloc is confusing since it makes people think > > it's byte count, not pages. Fix it. > > i think it has to be unsigned long. > > 67a2e213e7e937c41c52ab5bc46bf3f4de469f6e Thanks for the pinter. I wanted to have the smallest change. The commit leads me to change cma_release, trace_cma_alloc, cma_clear_bitmap and front_contig_range as well.(Not sure we have more. Will check). Ccing david@redhat.com for upcoming changing free_contig_range. > > > Link: https://lore.kernel.org/linux-mm/20210324043434.GP1719932@casper.infradead.org/ > > Cc: Matthew Wilcox > > Signed-off-by: Minchan Kim > > --- > > include/linux/cma.h | 2 +- > > mm/cma.c | 8 ++++---- > > 2 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/include/linux/cma.h b/include/linux/cma.h > > index 217999c8a762..a873edc20ca2 100644 > > --- a/include/linux/cma.h > > +++ b/include/linux/cma.h > > @@ -44,7 +44,7 @@ extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, > > unsigned int order_per_bit, > > const char *name, > > struct cma **res_cma); > > -extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, > > +extern struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align, > > bool no_warn); > > extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count); > > > > diff --git a/mm/cma.c b/mm/cma.c > > index 08c45157911a..24dc01e26d45 100644 > > --- a/mm/cma.c > > +++ b/mm/cma.c > > @@ -423,21 +423,21 @@ static inline void cma_debug_show_areas(struct cma *cma) { } > > * This function allocates part of contiguous memory on specific > > * contiguous memory area. > > */ > > -struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, > > +struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align, > > bool no_warn) > > { > > unsigned long mask, offset; > > unsigned long pfn = -1; > > unsigned long start = 0; > > unsigned long bitmap_maxno, bitmap_no, bitmap_count; > > - size_t i; > > + unsigned int i; > > struct page *page = NULL; > > int ret = -ENOMEM; > > > > if (!cma || !cma->count || !cma->bitmap) > > goto out; > > > > - pr_debug("%s(cma %p, count %zu, align %d)\n", __func__, (void *)cma, > > + pr_debug("%s(cma %p, count %u, align %d)\n", __func__, (void *)cma, > > count, align); > > > > if (!count) > > @@ -500,7 +500,7 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, > > } > > > > if (ret && !no_warn) { > > - pr_err_ratelimited("%s: %s: alloc failed, req-size: %zu pages, ret: %d\n", > > + pr_err_ratelimited("%s: %s: alloc failed, req-size: %u pages, ret: %d\n", > > __func__, cma->name, count, ret); > > cma_debug_show_areas(cma); > > } > > -- > > 2.31.0.291.g576ba9dcdaf-goog > > > >