public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Is this code right in zram?
@ 2012-05-31 21:43 John Moser
  2012-06-01  9:53 ` Borislav Petkov
  2012-06-04 12:08 ` Jerome Marchand
  0 siblings, 2 replies; 5+ messages in thread
From: John Moser @ 2012-05-31 21:43 UTC (permalink / raw)
  To: linux-kernel

before I go stomping all over other peoples' work and sending idiotic 
patches, I think I'll ask.  Since I have no clue what I'm doing.

in drivers/staging/zram.c out of 3.4 (I just grabbed the source hours 
ago), I see this on lines 810-822:

        /* Allocate the device array and initialize each one */
         pr_info("Creating %u devices ...\n", num_devices);
         zram_devices = kzalloc(num_devices * sizeof(struct zram), 
GFP_KERNEL);
         if (!zram_devices) {
                 ret = -ENOMEM;
                 goto unregister;
         }

         for (dev_id = 0; dev_id < num_devices; dev_id++) {
                 ret = create_device(&zram_devices[dev_id], dev_id);
                 if (ret)
                         goto free_devices;
         }

Curiosity got me to here:

http://lwn.net/Articles/147014/

So assuming this, what I see here is:

  - kmalloc(num_devices * sizeof(struct zram), GFP_KERNEL);
  - memset() that to 0
  - immediately fill in this RAM without reading it

I'm wondering what the immediate need is to fill the area with zeros?  
Also curious as to whether the kzalloc() thing should better be 
kcalloc(num_devices, sizeof(struct zram), GFP_KERNEL) as a matter of 
convention.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-06-04 12:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-31 21:43 Is this code right in zram? John Moser
2012-06-01  9:53 ` Borislav Petkov
2012-06-04 12:08 ` Jerome Marchand
2012-06-04 12:33   ` Joe Perches
2012-06-04 12:47     ` Jerome Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox