Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3299072rwb; Fri, 16 Dec 2022 12:52:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf4WLVEe+Rm0xLfe2QOLU0B5F+zysOttaLl3m1xet+p/JV2DqppGnBDVw7jIfml2/ckgCZl5 X-Received: by 2002:a05:6402:f24:b0:46d:ca42:2e59 with SMTP id i36-20020a0564020f2400b0046dca422e59mr33727502eda.11.1671223946082; Fri, 16 Dec 2022 12:52:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671223946; cv=none; d=google.com; s=arc-20160816; b=wlt1PWQfhPfDyKNNGL9nCYBLhEAh/PtsqsoZdVvI53Vj9+5MR1Em7j26qC7fiOgwas OTdRjMgMIh1UOU2wJuR3Vt8b1k6AeQggRSlyKCCvdr8ojb/kkqWp9bs77equdED6gLzl iHEp96/b2kW9Qu3OfTasrA8xcilSpAU1fmUEfCi2p467LacBzfmZxPhGjSjsgJX3m7Yc 8YmxKivQz8ls7nTLkT3uPzf+UPNJOh2EeYdvpxNtBMQW8veMlnoIG84w/1fFv0s34LuT 1d2dSKIRL2wLTzwmqoX9uEFvGejBqvMvdqQA8iTzRVz1a4QMh+2vjFd/9y5L9HO55TKc qP+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TsEKLROJI6bk+d/af34BtH3nHi+XT+AwCEfmZNUH3/Y=; b=SoZ/VQSUcyZ7UF2H0RGayisXFC3y2wT01Vrr9I/8Wj1w98dtlGoTpBswT1V8w0HgLX QG9/p31DhL7bMaVG7lyPe/tt0Ix345qUk30Bkry6332VCoPZlFcg8EO7pEIeE2mFNVRN v5EM1ZMLkLsXDXb16690o8ymNlY2CD1QgRy9DdsLkv/tG/zfqUkHgYOt+Q1bwhy+YlmG /mByacv7VpUA6wiv3OehpNXBYMdts+KtfMw3hxn7xfGg6YEkcZn5/R2QdchrmHJJb//Q aetYZnRWyKIBeLDVFbUxk1GlWgCg5IzRCFzSYKwuCkNg188f8okLMH2cgUT1uzxQDXaU NeQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@meta.com header.s=s2048-2021-q4 header.b="eg/nESr6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=meta.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d2-20020aa7d5c2000000b0046c8d52c8c7si3079316eds.177.2022.12.16.12.52.10; Fri, 16 Dec 2022 12:52:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@meta.com header.s=s2048-2021-q4 header.b="eg/nESr6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=meta.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231975AbiLPURc (ORCPT + 68 others); Fri, 16 Dec 2022 15:17:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231963AbiLPURV (ORCPT ); Fri, 16 Dec 2022 15:17:21 -0500 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC6C56A741 for ; Fri, 16 Dec 2022 12:17:20 -0800 (PST) Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BGJx5ZI011799 for ; Fri, 16 Dec 2022 12:17:20 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=s2048-2021-q4; bh=TsEKLROJI6bk+d/af34BtH3nHi+XT+AwCEfmZNUH3/Y=; b=eg/nESr6F77JzUbkWU0e8iE2X8/jNwrl9zRoWRDdZr9uOfV0IDl/ujcTuVTc15OXPMls qU20SlqzotONNGPF/XwPTBIXdMUmsF5JBreS/shSEouA+j7ohJczc3i9drTwXVqyWhF7 uzJGYjx4yBnaQLsTh/JEY3tCWGUdCWeiYeFclsfq/fjyvWuuXKDj+vPrgdxzm/RDEpzQ +DugdrXadzXsbN1rvNvYRc3gq07R5VlZ8ZMEfKFAi72eBjaPi13EDukrGm2vBM4HGWsT 0QBbcoQbnNkyhujIGVmQcO9VshkHIKrdtE0bV0512vMynv7F3sHtHUP0EpRQLVjo7UX3 LA== Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3mgm45uyg4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 16 Dec 2022 12:17:19 -0800 Received: from twshared24004.14.frc2.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c085:11d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 16 Dec 2022 12:17:18 -0800 Received: by devbig007.nao1.facebook.com (Postfix, from userid 544533) id 1A5B2D042AB7; Fri, 16 Dec 2022 12:17:10 -0800 (PST) From: Keith Busch To: , , Matthew Wilcox CC: Tony Battersby , Kernel Team , Keith Busch Subject: [PATCHv2 04/11] dmapool: cleanup integer types Date: Fri, 16 Dec 2022 12:16:18 -0800 Message-ID: <20221216201625.2362737-5-kbusch@meta.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221216201625.2362737-1-kbusch@meta.com> References: <20221216201625.2362737-1-kbusch@meta.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-ORIG-GUID: vhSY8vOHsHmUmbV2-dPGRoPkjZHkTU1j X-Proofpoint-GUID: vhSY8vOHsHmUmbV2-dPGRoPkjZHkTU1j X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-16_14,2022-12-15_02,2022-06-22_01 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tony Battersby To represent the size of a single allocation, dmapool currently uses 'unsigned int' in some places and 'size_t' in other places. Standardize on 'unsigned int' to reduce overhead, but use 'size_t' when counting all the blocks in the entire pool. Signed-off-by: Tony Battersby Signed-off-by: Keith Busch --- mm/dmapool.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/mm/dmapool.c b/mm/dmapool.c index 20616b760bb9c..ee993bb59fc27 100644 --- a/mm/dmapool.c +++ b/mm/dmapool.c @@ -43,10 +43,10 @@ struct dma_pool { /* the pool */ struct list_head page_list; spinlock_t lock; - size_t size; struct device *dev; - size_t allocation; - size_t boundary; + unsigned int size; + unsigned int allocation; + unsigned int boundary; char name[32]; struct list_head pools; }; @@ -73,7 +73,7 @@ static ssize_t pools_show(struct device *dev, struct de= vice_attribute *attr, cha mutex_lock(&pools_lock); list_for_each_entry(pool, &dev->dma_pools, pools) { unsigned pages =3D 0; - unsigned blocks =3D 0; + size_t blocks =3D 0; =20 spin_lock_irq(&pool->lock); list_for_each_entry(page, &pool->page_list, page_list) { @@ -83,9 +83,10 @@ static ssize_t pools_show(struct device *dev, struct d= evice_attribute *attr, cha spin_unlock_irq(&pool->lock); =20 /* per-pool info, no real statistics yet */ - size +=3D sysfs_emit_at(buf, size, "%-16s %4u %4zu %4zu %2u\n", + size +=3D sysfs_emit_at(buf, size, "%-16s %4zu %4zu %4u %2u\n", pool->name, blocks, - pages * (pool->allocation / pool->size), + (size_t) pages * + (pool->allocation / pool->size), pool->size, pages); } mutex_unlock(&pools_lock); @@ -133,7 +134,7 @@ struct dma_pool *dma_pool_create(const char *name, st= ruct device *dev, else if (align & (align - 1)) return NULL; =20 - if (size =3D=3D 0) + if (size =3D=3D 0 || size > INT_MAX) return NULL; else if (size < 4) size =3D 4; @@ -146,6 +147,8 @@ struct dma_pool *dma_pool_create(const char *name, st= ruct device *dev, else if ((boundary < size) || (boundary & (boundary - 1))) return NULL; =20 + boundary =3D min(boundary, allocation); + retval =3D kmalloc(sizeof(*retval), GFP_KERNEL); if (!retval) return retval; @@ -306,7 +309,7 @@ void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem= _flags, { unsigned long flags; struct dma_page *page; - size_t offset; + unsigned int offset; void *retval; =20 might_alloc(mem_flags); --=20 2.30.2