From patchwork Mon Aug 29 06:38:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Chen X-Patchwork-Id: 12957466 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 36B48ECAAD2 for ; Mon, 29 Aug 2022 06:35:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ABF05940009; Mon, 29 Aug 2022 02:35:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A6EBD940007; Mon, 29 Aug 2022 02:35:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95D5B940009; Mon, 29 Aug 2022 02:35:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 875A2940007 for ; Mon, 29 Aug 2022 02:35:20 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 593FE40AD5 for ; Mon, 29 Aug 2022 06:35:20 +0000 (UTC) X-FDA: 79851668400.24.64FFD75 Received: from 189.cn (ptr.189.cn [183.61.185.102]) by imf17.hostedemail.com (Postfix) with ESMTP id 4C6F240002 for ; Mon, 29 Aug 2022 06:35:18 +0000 (UTC) HMM_SOURCE_IP: 10.64.8.41:33464.1972940701 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-123.150.8.42 (unknown [10.64.8.41]) by 189.cn (HERMES) with SMTP id 440CB1002B3; Mon, 29 Aug 2022 14:35:11 +0800 (CST) Received: from ([123.150.8.42]) by gateway-153622-dep-84fc4d489d-ngzxf with ESMTP id f15f6262ff3f481d8b2da43890107d73 for karolinadrobnik@gmail.com; Mon, 29 Aug 2022 14:35:12 CST X-Transaction-ID: f15f6262ff3f481d8b2da43890107d73 X-Real-From: chensong_2000@189.cn X-Receive-IP: 123.150.8.42 X-MEDUSA-Status: 0 From: Song Chen To: karolinadrobnik@gmail.com, rppt@kernel.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Song Chen Subject: [PATCH 1/2] tools/libs/slab.c: fix compiling mistakes of uatomic_inc/uatomic_dec Date: Mon, 29 Aug 2022 14:38:41 +0800 Message-Id: <1661755121-3286-1-git-send-email-chensong_2000@189.cn> X-Mailer: git-send-email 2.7.4 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661754920; a=rsa-sha256; cv=none; b=Lkb8RcagEDgd1RI/IkUmr3ZBLlHrjQRy/mm8Nqwh9O37TXQcsLcIFkTYn0QbRGx4dgEgmm jOCpJ+/KcoKjkqIcn4+FQSucGBrdQi5KaVcarrdlYXdWUBKQSluTfUZl2XFjSnkEZ184ra 52MDpxFtlGe+bA6OOD+hf7zqKY8k9ng= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf17.hostedemail.com: domain of chensong_2000@189.cn designates 183.61.185.102 as permitted sender) smtp.mailfrom=chensong_2000@189.cn ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661754920; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=B0m2NhmRXHXfR/tgEQ6yWwqwqu6oq/e6DEw0n6blq84=; b=bSZgzUhkChTePalT26bCCOOPHid1ZhNr4KOIa24GV349RTZe5e8vqvcqJMfOUfBgJOImUQ U68FtGZylNzbM7SXDgtYEo48rLpRbNa/a3uyBiM3EruSz2jDk15MkPd1V9+0f6KU3YQtB0 DyeObIBM784imt8Zlm8if5kNtq+NhOk= Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf17.hostedemail.com: domain of chensong_2000@189.cn designates 183.61.185.102 as permitted sender) smtp.mailfrom=chensong_2000@189.cn X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 4C6F240002 X-Stat-Signature: ammrobcjussx4yiafd8pyx73tcy35br6 X-HE-Tag: 1661754918-599603 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001147, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: I tried to build tools/test/memblock and got such message: /usr/bin/ld: slab.o: in function `kmalloc': slab.c:(.text+0x2b): undefined reference to `uatomic_inc' /usr/bin/ld: slab.o: in function `kfree': slab.c:(.text+0x97): undefined reference to `uatomic_dec' collect2: error: ld returned 1 exit status I could find any definition or inplememtation of uatomic_inc/uatomic_dec in anywhere of the code base. So I use atomic_inc/atomic_dec_and_test to replace like other tests underneath tools/test, it works. Signed-off-by: Song Chen --- tools/lib/slab.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/lib/slab.c b/tools/lib/slab.c index 959997fb0652..8a5a8d536e35 100644 --- a/tools/lib/slab.c +++ b/tools/lib/slab.c @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include @@ -19,7 +19,7 @@ void *kmalloc(size_t size, gfp_t gfp) return NULL; ret = malloc(size); - uatomic_inc(&kmalloc_nr_allocated); + atomic_inc(&kmalloc_nr_allocated); if (kmalloc_verbose) printf("Allocating %p from malloc\n", ret); if (gfp & __GFP_ZERO) @@ -31,7 +31,7 @@ void kfree(void *p) { if (!p) return; - uatomic_dec(&kmalloc_nr_allocated); + atomic_dec_and_test(&kmalloc_nr_allocated); if (kmalloc_verbose) printf("Freeing %p to malloc\n", p); free(p);