public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] implement ksize()
Date: Sun, 3 Nov 2002 18:15:55 +0100	[thread overview]
Message-ID: <20021103181555.A6977@lst.de> (raw)

It's used to find out the effective allocation size of objects allocated
by kmalloc().  This is needed by the uClinux ports in many places but
seems also usefull for mmu-using ports.


--- 1.13/include/linux/slab.h	Wed Sep 25 20:41:05 2002
+++ edited/include/linux/slab.h	Sun Nov  3 03:08:32 2002
@@ -60,6 +60,7 @@
 
 extern void *kmalloc(size_t, int);
 extern void kfree(const void *);
+extern unsigned int ksize(const void *);
 
 extern int FASTCALL(kmem_cache_reap(int));
 
--- 1.156/kernel/ksyms.c	Thu Oct 31 10:28:34 2002
+++ edited/kernel/ksyms.c	Sun Nov  3 03:09:00 2002
@@ -104,6 +104,7 @@
 EXPORT_SYMBOL(remove_shrinker);
 EXPORT_SYMBOL(kmalloc);
 EXPORT_SYMBOL(kfree);
+EXPORT_SYMBOL(ksize);
 EXPORT_SYMBOL(vfree);
 EXPORT_SYMBOL(__vmalloc);
 EXPORT_SYMBOL(vmalloc);
--- 1.46/mm/slab.c	Fri Nov  1 16:34:38 2002
+++ edited/mm/slab.c	Sun Nov  3 13:18:29 2002
@@ -1871,6 +1871,22 @@
 	return cachep->objsize;
 }
 
+unsigned int ksize(const void *objp)
+{
+	kmem_cache_t *c;
+	unsigned long flags;
+	unsigned int size = 0;
+
+	if (objp) {
+		local_irq_save(flags);
+		c = GET_PAGE_CACHE(virt_to_page(objp));
+		size = kmem_cache_size(c);
+		local_irq_restore(flags);
+	}
+
+	return size;
+}
+
 kmem_cache_t * kmem_find_general_cachep (size_t size, int gfpflags)
 {
 	struct cache_sizes *csizep = malloc_sizes;

                 reply	other threads:[~2002-11-03 17:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20021103181555.A6977@lst.de \
    --to=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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