From patchwork Tue Feb 15 14:42:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 12747239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE9D7C4321E for ; Tue, 15 Feb 2022 15:36:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0C0A6B0078; Tue, 15 Feb 2022 10:36:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D93386B007B; Tue, 15 Feb 2022 10:36:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B714A6B007D; Tue, 15 Feb 2022 10:36:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0165.hostedemail.com [216.40.44.165]) by kanga.kvack.org (Postfix) with ESMTP id A206B6B0078 for ; Tue, 15 Feb 2022 10:36:40 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 688A981209 for ; Tue, 15 Feb 2022 15:36:40 +0000 (UTC) X-FDA: 79145416560.07.F1511DA Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf23.hostedemail.com (Postfix) with ESMTP id A9A9A140012 for ; Tue, 15 Feb 2022 15:36:39 +0000 (UTC) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21FDlHRk026435; Tue, 15 Feb 2022 14:43:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2021-07-09; bh=jyQLu/MDGC3ElNdObmQqBi7SsvI1ckwo5EJ2g4b+zIE=; b=N2v5FoQChWmF0MdChmXyq59WFt6gD+wat3SgmbXyXSFg1uscBtcNvwimWs4l4WzS4EUM mYqt0SQKLjV/fZYh2+SFBCKF9Qtenpar5XjrPFIi5sSDHTVD+REKVed12qKlYoZUQcQ2 +SWs7qNRzi96D+0/mdc4Bwt7D7jxYW8ZbmpfWvM8ul84K1Sm7PRG2pH14+RG35HcAvhC i8vgc4py6jKck+UTJF7CTtBzDNDI45pTvD8Y7BsyJ2qDBib9waqSfqxCWdjArSvUS0z+ sKIGoyiFWAvrGOcuPJ87Jxu76oFq47U/5eOARdfGO5S1PTPVyyEdthpZZRZGA2Bqt79e +w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3e88hgh4dw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Feb 2022 14:43:01 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21FEeVca085745; Tue, 15 Feb 2022 14:43:00 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by userp3020.oracle.com with ESMTP id 3e66bnpj23-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Feb 2022 14:43:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=anWX6EHP8wbGy9QGkX0RghWHErFOu+ScSc56E1EnOafNKM2vo6bdYHb7tk0E5yfBPrccSXXheLF1C87aNpd2j9r6Vm7Uqv/7WQ/rYa6ZeOxW1D7W+NoYlG7hRup1dTqOdTUeOlxvly3ZWEZ8UF3Ux3OkRK8mmuehRjJMS1UZEetdKFshdgbBsnzdMWa2CJvmV2q3V0OMr4V25fz1M/Q6hNOR9FEruMrQoxsmyX4OUKr9gpfd7TXG0UDWlDJishcGXPb0gZFt/DgYvptvnOaXR93bK/Lm2JfCz/K0Ba1lcF0WTvpGwYWojKWXyN/iXZY5OUc+SYZ3Jmr6IFMw9mZqyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jyQLu/MDGC3ElNdObmQqBi7SsvI1ckwo5EJ2g4b+zIE=; b=nz1dvb+VvCSWGIW1fXLarK6hLY5uAHiDPE1I5Kr51JJUc5TslHBkhpEDrX3StHOXG+edK3zSAqTD/nYr+euaKkGYLVMKj+OQNVYMEjCfdC4k1ss/xhJyIFtF/5IY4cC0aeH/6LuMNg1hyI9Qj3LygHstxBMyXr1/edPoOvTJAnBJKx9V317p8/6UA9tC2xes5/r1X4xGTn0U0KL19ie+jiXEgFKSTdweuur4EjDrUhKWZn+byeeWoh6MPRXVl0ghVmI8ObLzi30/+pyqMHMONp6BzAdJ8tdTZ8KZue3FBQL2Zq9k93GJ3VbIL7K9Ff9G4WOt6bqQmAk2ywO0KmH9nw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jyQLu/MDGC3ElNdObmQqBi7SsvI1ckwo5EJ2g4b+zIE=; b=U87u3npSwnP6wvrXgIol7k2F2yJsJwNqWpC6+X1+h/9+KJorngEG2YlK14uEWUjJ5/vVIxYbLInjl9SlzEv6WpiA+1CHTTkC8uzN0UOERyodk4gTliYcxMGenVNfnSwDmEJiulQxeHBd7DqlyAqIj92oPqEtMxfSpuSFEhSPo9E= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by CY4PR1001MB2197.namprd10.prod.outlook.com (2603:10b6:910:48::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15; Tue, 15 Feb 2022 14:42:58 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::899e:951a:8129:8ef1]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::899e:951a:8129:8ef1%4]) with mapi id 15.20.4975.019; Tue, 15 Feb 2022 14:42:58 +0000 From: Liam Howlett To: "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton Subject: [PATCH v6 05/71] radix tree test suite: Add allocation counts and size to kmem_cache Thread-Topic: [PATCH v6 05/71] radix tree test suite: Add allocation counts and size to kmem_cache Thread-Index: AQHYInpSmPfyQNs1dkCg4QuhDc3l0A== Date: Tue, 15 Feb 2022 14:42:57 +0000 Message-ID: <20220215144241.3812052-5-Liam.Howlett@oracle.com> References: <20220215143728.3810954-1-Liam.Howlett@oracle.com> <20220215144241.3812052-1-Liam.Howlett@oracle.com> In-Reply-To: <20220215144241.3812052-1-Liam.Howlett@oracle.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.34.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: cddaaf95-6783-43f7-7919-08d9f09175e3 x-ms-traffictypediagnostic: CY4PR1001MB2197:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2449; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 0nDjBRaoKtUel6qHEMWuSXHki9uJftEjh0Oe/2pTt0S6gcJj9XG8KKuN0blmNfPsikkPRPt4GguiTXrrH0UycsrRtzLnOnZWnYgzAH52V4QbXaxQKJbrPTMPJ+bpFUELB8snCrkK0Y38TEvn8EkgabCguSIscmrNKVX4ScXN4AGBdfPKolw43Rhl1lscRR0/Z+sAzSgAZtA8J9P8Cw61Si7dGAIfAFHoedZwiMCpkF6zjCJv0ya6Vc21ukaZUxX3fiHWn0taNa3i7CdTspp4ll3hDYP7Fc+BoxLAA0yB+freYq0NP9j1vwwC05vHrt4uSW7RdDRfTdT9wHsFVFarA+GWJf+nZiKTTOzoJmc8LNkPaGCki0HnyCAH6EsNo47At4n2D+JZbRkosQ1yRQEHxoccPpaD1NP14QDBToyoY3rfwo76LBkNIkzLA4TwYU7HmZljSej7OyatYW5+c+bIl5V/EacwSbXtUptZj9QJro+JO4ErXO3JUYR1hTg860ShRvaAPIHoMXPH1EOW4yl+FIxUiJGyMlu/bFgNjzm3uIr7rLLP6fM4nQdtbw2o5q2hGqH0gDFfHN+Uxk07VQKYvyMSHodNK6ra4KfhoRpo9oNLrHdWgX4Ryzl6BVO2VWwhgh/qqsA1YiArh065E5OB9xY+wzFrKInyAqe8k/rRoL677lUpj2xqOE8HNHGYXx7tXCKduJglIeum9UjQogcYgQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3022.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(316002)(186003)(66946007)(91956017)(6506007)(1076003)(508600001)(36756003)(64756008)(66446008)(8676002)(66476007)(2616005)(76116006)(110136005)(66556008)(6486002)(5660300002)(6512007)(2906002)(86362001)(83380400001)(26005)(38070700005)(71200400001)(38100700002)(122000001)(8936002)(44832011);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?qGfjGArOiwoKbs45uAbQDMp?= =?iso-8859-1?q?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FZLK07VYrOJwoGx2czpCdHALnhhATlIz9CiQ0?= =?iso-8859-1?q?WH3+7x1IKKxp1+LOi5KkdM6jNGxYGTnDxGEuwd3rJZMtqPIn5OOEt9lvCdce?= =?iso-8859-1?q?T3SDjR4SRzPh+7dyu0KyH8ixYlLOxfiuPEAcs63ZFO91hnKjdKdNSHLHYnJY?= =?iso-8859-1?q?al5XJpNjUhVSmXsTiIqHksNu2BYhTNXjaVMIEdPccS9B40qx3eN81b7Yqy2G?= =?iso-8859-1?q?Sk5XkQij8Idk/BSfAZp9WKE+kNMLTPxGQOXK1AUMUZVbXhnOI4G1eanx0lOH?= =?iso-8859-1?q?7USuDr9h00R9OkH+iwzvCS3uAFmVdDcPHvg2nJii7JkpRwilTjLlrbRLTyQr?= =?iso-8859-1?q?azhU60ZsrhYRyNjrXEXJditKapn5aVR8F5CbRNawbVeKyIyyj7BAZw/urgzL?= =?iso-8859-1?q?48boTVclMUxC4L/JtTd2hUEt0M0tINSZrd3dIyC9TubAtNZ80JcGRXxM9/9u?= =?iso-8859-1?q?l/ECFzJVuW4wLI4B/l9yH2XLDXH8XxcdzCPf5Q8WeUkQY3FvAgy6GgxlhllE?= =?iso-8859-1?q?75f262r8OY6u3TkqZvdQi1XEsdQIcc6yag12o1lVPVpN/cNu+yVOTAwQxmGP?= =?iso-8859-1?q?EY0RaLZv8y255nTRAk5sJIDDly+PS8Mo+ZWwa+HRf1NlAjrFZQc7hKT+Quj8?= =?iso-8859-1?q?Yp0TtWgBx3Ut5OvtacPXOUbPo9/EeQkTileTvQSy8YdDsQOr5cWUhv6Sy7JZ?= =?iso-8859-1?q?YnT9Oxl9MibWNF8IGmyIwuT43zSD4msC3LNWbBgU+gY/S3jPYqzbRbeLkLFk?= =?iso-8859-1?q?=3D?= MIME-Version: 1.0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: cddaaf95-6783-43f7-7919-08d9f09175e3 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Feb 2022 14:42:57.7465 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: SOkZMUNSIm5JQ3XgdB1XhOh7PxH2DCso7jRxChYvRzuZk3Z1UsqET+EnsTnJJydxk9nC8Z1viC2bjUXwJcQ9OA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2197 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10258 signatures=673431 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202150085 X-Proofpoint-GUID: i5xxaplzPASiDDUdSPeDoxzUbJxvFuwx X-Proofpoint-ORIG-GUID: i5xxaplzPASiDDUdSPeDoxzUbJxvFuwx Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=N2v5FoQC; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=U87u3npS; spf=none (imf23.hostedemail.com: domain of liam.howlett@oracle.com has no SPF policy when checking 205.220.177.32) smtp.mailfrom=liam.howlett@oracle.com; dmarc=pass (policy=none) header.from=oracle.com X-Rspamd-Server: rspam07 X-Rspam-User: X-Rspamd-Queue-Id: A9A9A140012 X-Stat-Signature: c7i6fix4nxjs41xj9n9trnnhjeetbfua X-HE-Tag: 1644939399-162300 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: From: "Liam R. Howlett" Add functions to get the number of allocations, and total allocations from a kmem_cache. Also add a function to get the allocated size and a way to zero the total allocations. Signed-off-by: Liam R. Howlett --- tools/testing/radix-tree/linux.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/testing/radix-tree/linux.c b/tools/testing/radix-tree/linux.c index 00ee01a14652..f95e71d65f00 100644 --- a/tools/testing/radix-tree/linux.c +++ b/tools/testing/radix-tree/linux.c @@ -25,6 +25,8 @@ struct kmem_cache { void *objs; void (*ctor)(void *); unsigned int non_kernel; + unsigned long nr_allocated; + unsigned long nr_tallocated; }; void kmem_cache_set_non_kernel(struct kmem_cache *cachep, unsigned int val) @@ -32,6 +34,26 @@ void kmem_cache_set_non_kernel(struct kmem_cache *cachep, unsigned int val) cachep->non_kernel = val; } +unsigned long kmem_cache_get_alloc(struct kmem_cache *cachep) +{ + return cachep->size * cachep->nr_allocated; +} + +unsigned long kmem_cache_nr_allocated(struct kmem_cache *cachep) +{ + return cachep->nr_allocated; +} + +unsigned long kmem_cache_nr_tallocated(struct kmem_cache *cachep) +{ + return cachep->nr_tallocated; +} + +void kmem_cache_zero_nr_tallocated(struct kmem_cache *cachep) +{ + cachep->nr_tallocated = 0; +} + void *kmem_cache_alloc(struct kmem_cache *cachep, int gfp) { void *p; @@ -63,7 +85,9 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, int gfp) memset(p, 0, cachep->size); } + uatomic_inc(&cachep->nr_allocated); uatomic_inc(&nr_allocated); + uatomic_inc(&cachep->nr_tallocated); if (kmalloc_verbose) printf("Allocating %p from slab\n", p); return p; @@ -73,6 +97,7 @@ void kmem_cache_free(struct kmem_cache *cachep, void *objp) { assert(objp); uatomic_dec(&nr_allocated); + uatomic_dec(&cachep->nr_allocated); if (kmalloc_verbose) printf("Freeing %p to slab\n", objp); pthread_mutex_lock(&cachep->lock); @@ -124,6 +149,8 @@ kmem_cache_create(const char *name, unsigned int size, unsigned int align, ret->size = size; ret->align = align; ret->nr_objs = 0; + ret->nr_allocated = 0; + ret->nr_tallocated = 0; ret->objs = NULL; ret->ctor = ctor; ret->non_kernel = 0;