From patchwork Thu Sep 26 12:00:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang Gao X-Patchwork-Id: 13813352 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 A7367C369CD for ; Thu, 26 Sep 2024 12:01:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F0266B008A; Thu, 26 Sep 2024 08:01:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A1FC6B008C; Thu, 26 Sep 2024 08:01:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2419E6B0092; Thu, 26 Sep 2024 08:01:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 064D56B008A for ; Thu, 26 Sep 2024 08:00:59 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7A16A810CE for ; Thu, 26 Sep 2024 12:00:59 +0000 (UTC) X-FDA: 82606748238.22.9C9A50F Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by imf21.hostedemail.com (Postfix) with ESMTP id 92C291C0033 for ; Thu, 26 Sep 2024 12:00:57 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=G3WyHqLB; spf=pass (imf21.hostedemail.com: domain of gxxa03070307@gmail.com designates 209.85.215.180 as permitted sender) smtp.mailfrom=gxxa03070307@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727351995; a=rsa-sha256; cv=none; b=pUvNK4Gi9Z9F24EYhb1hGeYxh5Er3EtAfbBfkmbjCXc40zJmUUYbKr5fxb3WwMseIddTk9 a3uMZ70V4gxJDR6OZcCeOYZO+5rgHjJQW89a4RZgobXvphYezGsn+lYGGczMUkyoi/UEDP AOvnl0okh/FBtGeJExVH8qvZK632z90= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=G3WyHqLB; spf=pass (imf21.hostedemail.com: domain of gxxa03070307@gmail.com designates 209.85.215.180 as permitted sender) smtp.mailfrom=gxxa03070307@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727351995; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=r7KCWGxZhj1y1aKLk6OuylPhX7GhAPrJcm5GWveFmkw=; b=7rGdqmQxY6gjLHSKVa/lyQFQs6XF8P5TesOo1UFdo/4kVnyQ0oUqa6gli0AlXIrjAL/vKl UGM/yhLo8tuczSHUYNF8ShWyo1X7vH0Kx/AZ5Dc2Xvfv6Ov8vuZD5hmMwWNlkG1kssVl2n N9rM35RfgbjdV2jKVglOLX/39HK154I= Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-7db1f13b14aso681679a12.1 for ; Thu, 26 Sep 2024 05:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727352056; x=1727956856; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=r7KCWGxZhj1y1aKLk6OuylPhX7GhAPrJcm5GWveFmkw=; b=G3WyHqLBjxD26MoAk/mY+YwQ/c4EOX2A1pc0aMdZ4WPps1gFZxt8Rji1bfJIoDYf6j bVX5u8JExH8nMBtyBlvZbochmT49TZzt66taDoOuzVehKLw0sZReAAIO8AqUr6OnlnkA qtlfBRSSE/C39dBwEc0V36ProcPMl6Ptklfw/oxwFKRSzkt2rfIS3y2D2vKpq4tEObg7 Tp1qg0PWNbj/5sGZWycBlCRErP4G8UsBBa0yeqKU5w5AVNiJFDQdgUu7jwVX6Ers3t7q shQSedDG/mY1FqFYBMriWqId8cBIGR/IGnIwuhPth7oDgb7Ht3lcIz6xCmgRk1Tiy3PV lshg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727352056; x=1727956856; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=r7KCWGxZhj1y1aKLk6OuylPhX7GhAPrJcm5GWveFmkw=; b=f+167TL5mjkRvbQHaGn17C+oYmxgEXs/18eG+0rssoG+Lqm1y0OpksyL0wU4vaQzlE lihsCw5GowcGzVt7iP8s2tOHMRNEVOESmao7T2uZFwT2yyY2TQPJb0S/5ggIaaX/ZPo8 NPDb0SXTKrQCohkatAutY5+KZhpYfKVD6MTBScg9+fL1vzg5x5uuJllKTXzbkPiLlL/5 iSpeeAfCTWF2ZCAjxFNFchQwoEoAXKfa7U4ta0L4vlhHrw2hLlhs/mtCcEYCxsG2fIiF NCbhHS9ySYIeMbWt2ufkY9pHnc/t1cwYuyTlkdqzAPmgx8MIuASS0pLm6NEBsaLUJhn8 1wqg== X-Gm-Message-State: AOJu0YzYZh4NvdJjz99A0xy+5D+j+Rtrbng6vYgEIv/p3wrRp8grwMT7 dlhxgqBZmKGXCUgxhvSruFtNyBTdBh4kVgBGzpdEU68mlJNRmE4HFSYXlw== X-Google-Smtp-Source: AGHT+IESzLMriRLSPqkZ4Cp7hI+8v1XHdKwNCcIXZ+c9djXqMKBez3id/sdylBSuj2PoBH2dp+k7iA== X-Received: by 2002:a05:6a20:cd92:b0:1d2:e807:b65b with SMTP id adf61e73a8af0-1d4d4b9bcddmr7864536637.37.1727352055854; Thu, 26 Sep 2024 05:00:55 -0700 (PDT) Received: from xiaoa.mioffice.cn ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71afc967539sm4323103b3a.147.2024.09.26.05.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 05:00:55 -0700 (PDT) From: Xiang Gao To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, gaoxiang17 Subject: [PATCH] mm/cma: print total and used count in cma_alloc() Date: Thu, 26 Sep 2024 20:00:49 +0800 Message-Id: <20240926120049.321514-1-gxxa03070307@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Stat-Signature: od98cmiyrp7x6dsg1m4kaiuh3f1r7odi X-Rspamd-Queue-Id: 92C291C0033 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1727352057-778622 X-HE-Meta: U2FsdGVkX1+SlLjxDqI6cgdvOgGfyTZRNcS41H6Mt1zgVJ3wIUDrTgbZd/Sr5l30eqNGxcuDp4CrhM4rR9u/+l8nu//4rmeLq6iecL/ieb4VJb72mok10qVxY2pDoR4KFCvOyDXl72XzQLOzssu7Fxxin0718k0VtQn9A5AJN0EhT27Sni+raQ4uoX5Ep81TDAcK+s8BQ+TPkUe2YqQgetKRWj4CQL2H2kBwtFoEWrqCzpie3GCOqwFLkv9kILoWOKeWZyukajxYtYT+5xkDNBmjjokXpnrA8ZDlZGRE006PrAVjcSPAIRM8l3I7rQSfx2CV0V5wDdjYgwaPIvehT/x+Z1XJG5dHNQV53parIsxR9HRLAXlbqTQFp/Nk5dCrUO7aSj7w3ZFRMT03IHAFggufBcGe9pFzBVkNufIuJrcvf/DlKI0tRP9yG59AVY/Pll9d8UPXgWNiNE4zpC1gk/HUG1EkI7gdku2Hdo97ixD5m0GV5CW4p4BwTmIwtJSZn1rwj//055dml6spbK38In9hB4rWaQ2HWFbV4uF0yvTB2TQ3bKEeQGI/K/5dt7mX91VbE1ju7G/XS5BMeBvIprJ/AfJA1rLPtnLyHbRW6pBT9tLM0b7gtgiJLnbXUvqs9FcZuyqMsc2hJ6BWkMT1+09nv6qTewdBjylY9sSM8iRX8J5nhBDgsxXJ77J3vv0HQ2OqGvAq4/q+JGhjWPLPM9KYyS2CdNN2dbkfHe5n0pxTcw39VvhEfOEWYuxlqpGRQ/SRouACoJyQI8IC2HsB19AGEKLR0kkHeuUj0M9TueH6p4Nw8OX+wKnSai5U+qn371Q9N74u+oO7zgccvcqf/AHOJGGel7J31o+jVRSUtIsKYNSK6pBLuKoTTtbbVEUZVCzmLH9iDGy08Ojb2DfObM+xrXtDoqOq2wnL1pTA4FYJ16gDjuPsvFYnVny/TYAcLHI7Nhk+jFMHwJQCPRz ZHcRXf9I 3YVHB2QVdlsJJtX6SEYs2oA7peD6AGyC9u4Ci8Cq7D/YHFiAMbGrZj1vKFAASGzzRhbJcs2tKXooCV1DJZCh9p9MMAqBmQTIXnDub3Y2d2uq2XA20R+GP4pVQ8Ckkg8MmjlmGaX6d5EvKwRA4tOy980I2EjzSQh3ITLoBMgzcyjqb/8xjYaPpQdIo05UVkO1PyWzrCuZZ7yw1B3SY0zd72VN6iNIyBuJX3jIgn8fsUKNioOOWwL+4ShZ/U2hn9FdWuTmwhPxieVcFR6mOr7jmrQT3q5o9LJp2VBWPtD8m/LwZv1g4m9bpFECl12l/A9s1k4LSGmlMWGSQjDuKkX1HYXPZXQiSJlfjVWPat5Ak9DY5VCJyBtg3tSQXAW4UtRCrkR8oUkbWpR+4Oj1DpZ7p051xQgSQnnPFYJAJjWs1OEVpzuY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.007833, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: gaoxiang17 before: [ 24.407814] cma: cma_alloc(cma (____ptrval____), name: reserved, count 1, align 0) [ 24.413397] cma: cma_alloc(cma (____ptrval____), name: reserved, count 1, align 0) [ 24.415886] cma: cma_alloc(cma (____ptrval____), name: reserved, count 1, align 0) after: [ 24.097989] cma: cma_alloc(cma (____ptrval____), name: reserved, total count 16384, used count: 64, request count 1, align 0) [ 24.104260] cma: cma_alloc(cma (____ptrval____), name: reserved, total count 16384, used count: 65, request count 1, align 0) [ 24.107504] cma: cma_alloc(cma (____ptrval____), name: reserved, total count 16384, used count: 66, request count 1, align 0) Signed-off-by: gaoxiang17 --- mm/cma.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mm/cma.c b/mm/cma.c index 2d9fae939283..fc35a86aa82f 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -403,6 +403,17 @@ static void cma_debug_show_areas(struct cma *cma) spin_unlock_irq(&cma->lock); } +static unsigned long cma_get_used(struct cma *cma) +{ + unsigned long used; + + spin_lock_irq(&cma->lock); + used = bitmap_weight(cma->bitmap, (int)cma_bitmap_maxno(cma)); + spin_unlock_irq(&cma->lock); + + return used << cma->order_per_bit; +} + static struct page *__cma_alloc(struct cma *cma, unsigned long count, unsigned int align, gfp_t gfp) { @@ -420,8 +431,8 @@ static struct page *__cma_alloc(struct cma *cma, unsigned long count, if (!cma || !cma->count || !cma->bitmap) return page; - pr_debug("%s(cma %p, name: %s, count %lu, align %d)\n", __func__, - (void *)cma, cma->name, count, align); + pr_debug("%s(cma %p, name: %s, total count %lu, used count: %lu, request count %lu, align %d)\n", __func__, + (void *)cma, cma->name, cma->count, cma_get_used(cma), count, align); if (!count) return page;