Menu

#21 Bug in set_hashsize allocate more ram then needed

v1.6
open-fixed
nobody
Bug (12)
5
2009-08-10
2009-08-10
No

in set_hashsize
796
797 printk(KERN_INFO "netflow: allocating new hash table %u -> %u buckets\n",
798 ipt_netflow_hash_size, new_size);
799 new_hash = alloc_hashtable(sizeof(struct list_head) * new_size);
800 if (!new_hash)
801 return -ENOMEM;

this part allocate more ram because alloc_hashtable has inside multilayer on sizeof(struct list_head)
799 new_hash = alloc_hashtable(sizeof(struct list_head) * new_size);

774 static struct hlist_head *alloc_hashtable(int size)
775 {
776 struct hlist_head *hash;
777
778 hash = vmalloc(sizeof(struct list_head) * size);
779 if (hash) {
780 int i;
781
782 for (i = 0; i < size; i++)
783 INIT_HLIST_HEAD(&hash[i]);
784 } else
785 printk(KERN_ERR "netflow: unable to vmalloc hash table.\n");
786
787 return hash;
788 }

799 new_hash = alloc_hashtable(sizeof(struct list_head) * new_size);
must be changed to
799 new_hash = alloc_hashtable(new_size);

Discussion

  • ABC

    ABC - 2009-08-10

    You are very right, thanks!

    ps. 'multilayer' probably you mean 'multiplier'? Please say more clearly next time, it is very hard to understand you.

    pps. Also I just noticed, it should be allocated not sizeof(struct list_head) but sizeof(struct hlist_head), which is smaller size.

    Commited both changes into cvs.

     
  • ABC

    ABC - 2009-08-10
    • status: open --> open-fixed
     
  • Evgen Bendyak

    Evgen Bendyak - 2009-08-10

    sorry my English not so good and also in fire-fox some plugin present witch make auto check and fix of english words, so it make some stupid changes some times.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.