From patchwork Wed Sep 18 12:43:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang Gao X-Patchwork-Id: 13806871 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 0B724CCD1A3 for ; Wed, 18 Sep 2024 12:43:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 625196B0082; Wed, 18 Sep 2024 08:43:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D52A6B0083; Wed, 18 Sep 2024 08:43:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49CC66B0085; Wed, 18 Sep 2024 08:43:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2A84B6B0082 for ; Wed, 18 Sep 2024 08:43:37 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B91AD1205A6 for ; Wed, 18 Sep 2024 12:43:36 +0000 (UTC) X-FDA: 82577825232.23.A415DCF Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf17.hostedemail.com (Postfix) with ESMTP id 10FB940006 for ; Wed, 18 Sep 2024 12:43:33 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=RdBdv4jW; spf=pass (imf17.hostedemail.com: domain of gxxa03070307@gmail.com designates 209.85.214.181 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=1726663265; 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=QTKZFNlHn9F703T0EyhCC2dGWtgK4Zdb4VWczLMsNE4=; b=C66kLewIcIUKWEaT5mLZGBzCPb8JNQihTkA4i37ArgWYaaNNoLFLG8/ENk+YnKhMDtMNWI aBVwqlu9ucB6d2Ix5ahKfpA6qMayCKmhL2CH5Pa4IQgffAe85X5G5hAzdEtEZOetM10Lcb HxRkqzS/9LL8K7N0C5jbyJIRkDU9Pf0= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=RdBdv4jW; spf=pass (imf17.hostedemail.com: domain of gxxa03070307@gmail.com designates 209.85.214.181 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=1726663265; a=rsa-sha256; cv=none; b=a4rCBCOTIHn9wcoE1rNZ6t8OqGJI+U/XaU4HgY3le7x+cqE3L/N4+G5ec07/KUg0pIiEaL J1LQf16wXlunr0Xb7Cb0GOnVV3H7mQso1WbQ2RLC8aSE8okJ2F94IzPVMgm7ogpVAHTTqH 1vjcr7idlUFUhfcALv0HoztuRtnE+14= Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2068acc8b98so61633565ad.3 for ; Wed, 18 Sep 2024 05:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726663413; x=1727268213; 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=QTKZFNlHn9F703T0EyhCC2dGWtgK4Zdb4VWczLMsNE4=; b=RdBdv4jWfBe+/HIrfB3Rb4g0f/k2cVPpHt8mPT2H2wNBoFmSkQuF9vzf/T11a0zQyT 0h4RJZzHtCsFj5g/Os7YH5rYnOmCNLYZa6ptMrro+GvwWR978xWx211TyEistqu5Ipgo ncX2QDhbfQRoFvh0XLcgWxy1ipOZ+7ItV1EgEP4vsdaBSUF3Q2aGBKs38ZccT2Ybs7SP 2jS6IVIZoy1r83+IEYu425mDqwqWpeGHDALq3RV26x39jKhX8SPVaVkCpKCNwf1Q8LAO 0+xzIhT5HD/aAhWCmqDZcdNenifmwCOziTi86PiYbUld9e0w+l1+4UydTGvxa0nnX7gb fdxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726663413; x=1727268213; 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=QTKZFNlHn9F703T0EyhCC2dGWtgK4Zdb4VWczLMsNE4=; b=GkNXDRWDRG9xkmHbdK+xJkQsBGrP203DawIlLPPFP3wqOUGQS/1og/ctMKONXhRlv6 BTN5I8NRcnMkKrMlrB/UNkZZ1ns4iWoMPKaDF1m1g9AQN6AJjk+wEDNdHa/P5UnpKqb5 7VPbMWIIX/T1A4ZTaa7fPi1gzIwVSIzpWDpC6amtMcqCgBIPOneJqvbdycD1lW+3As4Z E38DyWKa3dXPTMbisAWZrBlnSyW0ZdfvlDP00Z/rikmKYHf1uCLTcHolR0TBmYx14/fl r2CvHn1WlkktHnpA0P3fY8z5IPI9cB7d27xrBwWJEPBJYN7RssEq2Oej514rDBsixNY3 H1kQ== X-Gm-Message-State: AOJu0Yx10FjPbYjRKf3hR30MVrFs8r1baBpXT6iw9xBodC39XQnnFIDv 9aHCQ8QqwNfriO1N2RB/xg8U3ONmOoHoTaoN6rwkffVmrgzsPms1FEHOjjSL X-Google-Smtp-Source: AGHT+IH1JT2cZpqD8lenikRQuRcKc8hOZcbDHixmBaN7+AxopIarzf6KThf3RbADL6MSFjP80r9wsA== X-Received: by 2002:a17:903:11ce:b0:207:6e8:edb8 with SMTP id d9443c01a7336-2076e364015mr305233115ad.20.1726663412577; Wed, 18 Sep 2024 05:43:32 -0700 (PDT) Received: from xiaoa.mioffice.cn ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-207946f3595sm64238325ad.185.2024.09.18.05.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Sep 2024 05:43:31 -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.c: To better understand cma area during debugging, add total and used count logs to in cma_alloc Date: Wed, 18 Sep 2024 20:43:25 +0800 Message-Id: <20240918124325.109236-1-gxxa03070307@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 10FB940006 X-Stat-Signature: gbg9iaxamzy5o59r4i1h3qs8dkb74w93 X-Rspam-User: X-HE-Tag: 1726663413-472867 X-HE-Meta: U2FsdGVkX18oJOHWCJ+7MVrTxl/rDtag6KjASTyrayCrCO1YOi0eKGE9IbViDl5MsdOXkNG7wsUQQtrw3y2c+k25iWEpHVrUP1/L5iJ6DzExY7325GiaWLYh1WUMODQ2dIsitxRjnYRHXGwQpnkcrGARO2F2UJ0+eiyYJrGrWiKkzpryVaYYbV8u4WjmtLhgPHL3bXsHBLraPKcmqH0FLKVDaQmvePDXSpGnVdY1ooDtE3zKjRzRMy4GWcvkO+HZp1gJkU/bUoyqalchsKCdvmyVaXLaYOmt6CZJXhRnISp6X8mFP//eOhU701/rjPrCM6JUJOxysAGclxyFuw7WcIhq/5uJxy26ACZ2W2jJpvl6Bjx/WidcSkO/XCkbfV7Y6AyQI8tJDeJngNqDTfDKJnXLfi/BoH6nYQUARURM/gbZBUiSkwCkNBrfH8MKtostKaW+crzlIow5htvXmAyZOQBkDcQbWJZR+beCbTEB1UBgC6QkkvsShXdMu4aWDn3MglRohY7p4j0Q8Y7EzWhI1a0ertK5VU/7mbfMRu9G8dcrtdoOgzBb+B9h1y4btrrdEPMZrWnO1J0JyMBLZRmBtqQuEP4M0EdH7iOcKY2WMl+lRBu1mjVnPZ5sfVOFd0yjIXzJutCHaRkC2QOpSJbJSonsoOxqqeCwNyxI/Ji88WszV0hLsv1rbdFVpn+LH3URPyNKSf6nA/LTMt7qqYHUO3SFkOwmj8P39DlwHISau9lngAWAfdr+xha7n6WZaRbudCbk6+xNqBYke9pMIkuhaAEctptjxm/CINj8VLZhLSYbHT5MGBWYhf7SsOxX5nf5AuMuQUKjpvO75EJFBuP15/RsyF1B3h+DKvrX/9st5p6VB9ngy0Os/12nqUK8eub3E4EgYlfkfcLZpX+3TTC8g7+Zt/9YlIa6NFYKnNa8sLnG16ByuYqXx0Gdtntw1QISGsLz95ig7x2Y+ZOhyd8 Ov6pIwjK 6EDYTW+oJsMeMSen0AsP6FUQvywRQimn3DDNrRWcmRmIxupkQ9WV91SM1lSB7KcXPiI9oXcrcij5oG5f8ucB62AD1hn1wYb4QpbzJIuLcyLZvnFEpmHx81gdz3XALgllvL1JJim9XywtK/zshw3qvLY0Acw03tr/2uRvRm19Sv5ThdxlJfp7qiFdMjQPTP0KydizHGsgrws2nsGFTY2QrSz/Qh2s0DMOSOhnTaA6XM3wn/sJV26/kR4rc0oNda9ttxxkTnsaxW+EZ57vsCe3H0duYEmL7YrsJqn1QcLbYxhuU7uZUS/pLwe3a/6XpOXivoIiGeqarTwr4NC4qT3wml45J6lGRp0CfsnwdJHgNJ9vCIvqLeOiMDBv8GPgUKXk9n+DCSjHaSTTvKBvcyg8HcqEy+vwVsssfNPs7B0pxlKa0eOx+LTxjaHBInonhkU3U4hMOkHp4229kvrI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000165, 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 [ 24.225125] cma: cma_alloc(cma (____ptrval____), name: reserved, total count 16384, used count: 64, request count 1, align 0) [ 24.231963] cma: cma_alloc(cma (____ptrval____), name: reserved, total count 16384, used count: 65, request count 1, align 0) [ 24.235712] 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 3e9724716bad..cceff3b6a79e 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 (unsigned long)used << cma->order_per_bit; +} + /** * cma_alloc() - allocate pages from contiguous area * @cma: Contiguous memory region for which the allocation is performed. @@ -430,8 +441,8 @@ 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;