Hi Kirill, On 7/13/07, Kirill Korotaev <dev@sw.ru> wrote:Well, it's not too hard to guess: struct dentry is 124 bytes on i386 so kmem_cache_zalloc over it is bound to be slower tha kmem_cache_alloc as most members are initialized to non-NULL. And if you're into micro-benchmarks, here's one: d_alloc takes 182.75ns d_alloc_zalloc takes 315.89ns So definitely NAK for Denis' patch. Pekka #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <string.h> #include <time.h> struct dentry { void *a; void *b; void *c; void *d; void *e; void *f; void *g; void *h; unsigned char d_iname[36]; }; #define NR_ITERS 1000000 #define MAX_DENTRIES (NR_ITERS*2) static unsigned long offset; static struct dentry dentries[MAX_DENTRIES]; static inline void *__kmalloc(void) { void *p = &dentries[offset++]; if (offset == MAX_DENTRIES) offset = 0; return p; } void *kmalloc(size_t sz) { return __kmalloc(); } struct dentry *d_alloc(const char *name) { struct dentry *ret = kmalloc(sizeof *ret); if (ret) { ret->a = NULL; ret->b = NULL; ret->c = NULL; ret->d = NULL; ret->e = (void *) 0xdeadbeef; ret->f = (void *) 0xdeadbeef; ret->g = (void *) 0xdeadbeef; ret->h = (void *) 0xdeadbeef; strcpy(ret->d_iname, name); } return ret; } static inline void * __memset_generic(void * s, char c,size_t count) { int d0, d1; __asm__ __volatile__( "rep\n\t" "stosb" : "=&c" (d0), "=&D" (d1) :"a" (c),"1" (s),"0" (count) :"memory"); return s; } void *kzalloc(size_t sz) { void *p = __kmalloc(); if (p) __memset_generic(p, 0, sz); return p; } struct dentry *d_alloc_zalloc(const char *name) { struct dentry *ret = kzalloc(sizeof *ret); if (ret) { ret->e = (void *) 0xdeadbeef; ret->f = (void *) 0xdeadbeef; ret->g = (void *) 0xdeadbeef; ret->h = (void *) 0xdeadbeef; strcpy(ret->d_iname, name); } return ret; } int main(int argc, char *argv[]) { struct timeval start, end; unsigned long long usec; int i; gettimeofday(&start, NULL); for (i = 0; i < NR_ITERS; i++) { struct dentry *dentry = d_alloc("root"); if (!dentry || dentry->a != NULL) abort(); } gettimeofday(&end, NULL); usec = end.tv_usec + 1000000*(end.tv_sec - start.tv_sec) - start.tv_usec; printf("d_alloc takes %0.2lfns\n", (double)usec * 1000 / NR_ITERS); gettimeofday(&start, NULL); for (i = 0; i < NR_ITERS; i++) { struct dentry *dentry = d_alloc_zalloc("root"); if (!dentry || dentry->a != NULL) abort(); } gettimeofday(&end, NULL); usec = end.tv_usec + 1000000*(end.tv_sec - start.tv_sec) - start.tv_usec; printf("d_alloc_zalloc takes %0.2lfns\n", (double)usec * 1000 / NR_ITERS); return 0; } -
| Greg KH | Og dreams of kernels |
| Jens Axboe | [PATCH 31/33] Fusion: sg chaining support |
| Arnd Bergmann | Re: finding your own dead "CONFIG_" variables |
| Mark Brown | [PATCH 2/2] Subject: natsemi: Allow users to disable workaround for DspCfg reset |
| Tony Breeds | [LGUEST] Look in object dir for .config |
git: | |
| Brian Downing | Re: Git in a Nutshell guide |
| John Benes | Re: master has some toys |
| Matthias Lederhofer | [PATCH 4/7] introduce GIT_WORK_TREE to specify the work tree |
| Alexander Sulfrian | [RFC/PATCH] RE: git calls SSH_ASKPASS even if DISPLAY is not set |
| Junio C Hamano | Re: Rss produced by git is not valid xml? |
| Linux Kernel Mailing List | iSeries: fix section mismatch in iseries_veth |
| Linux Kernel Mailing List | ixbge: remove TX lock and redo TX accounting. |
| Linux Kernel Mailing List | ixgbe: fix several counter register errata |
| Linux Kernel Mailing List | b43: fix build with |
