From: Song Chen <chensong_2000@189.cn>
To: karolinadrobnik@gmail.com, rppt@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Song Chen <chensong_2000@189.cn>
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 [thread overview]
Message-ID: <1661755121-3286-1-git-send-email-chensong_2000@189.cn> (raw)
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 <chensong_2000@189.cn>
---
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 <stdio.h>
#include <string.h>
-#include <urcu/uatomic.h>
+#include <linux/atomic.h>
#include <linux/slab.h>
#include <malloc.h>
#include <linux/gfp.h>
@@ -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);
--
2.25.1
next reply other threads:[~2022-08-29 6:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-29 6:38 Song Chen [this message]
2022-08-29 7:11 ` [PATCH 1/2] tools/libs/slab.c: fix compiling mistakes of uatomic_inc/uatomic_dec Huang, Shaoqin
2022-08-29 8:23 ` Mike Rapoport
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1661755121-3286-1-git-send-email-chensong_2000@189.cn \
--to=chensong_2000@189.cn \
--cc=karolinadrobnik@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rppt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).