Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756584Ab2JWCBB (ORCPT ); Mon, 22 Oct 2012 22:01:01 -0400 Received: from ozlabs.org ([203.10.76.45]:54504 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756496Ab2JWCA4 convert rfc822-to-8bit (ORCPT ); Mon, 22 Oct 2012 22:00:56 -0400 From: Rusty Russell To: sjur.brandeland@stericsson.com, Amit Shah Cc: "Michael S. Tsirkin" , Linus Walleij , Masami Hiramatsu , Ohad Ben-Cohen , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, sjurbren@gmail.com, Sjur =?utf-8?Q?Br=C3=A6ndeland?= Subject: Re: [PATCHv7 2/4] virtio_console: Use kmalloc instead of kzalloc In-Reply-To: <1350287856-5284-3-git-send-email-sjur.brandeland@stericsson.com> References: <1350287856-5284-1-git-send-email-sjur.brandeland@stericsson.com> <1350287856-5284-3-git-send-email-sjur.brandeland@stericsson.com> User-Agent: Notmuch/0.14 (http://notmuchmail.org) Emacs/23.4.1 (i686-pc-linux-gnu) Date: Tue, 23 Oct 2012 12:06:34 +1030 Message-ID: <87d30ahsv1.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1400 Lines: 40 sjur.brandeland@stericsson.com writes: > From: Sjur Brændeland > > Avoid the more cpu expensive kzalloc when allocating buffers. > Originally kzalloc was intended for isolating the guest from > the host by not sending random guest data to the host. But device > isolation is not yet in place so kzalloc is not really needed. > > Signed-off-by: Sjur Brændeland This looks fine to me. This is *why* the device gives us the length which was written; we can trust that, even if we can't trust the writer of data. (In theory: noone has implemented such a system, yet). Applied. Rusty. > diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c > index c36b2f6..301d17e 100644 > --- a/drivers/char/virtio_console.c > +++ b/drivers/char/virtio_console.c > @@ -349,7 +349,7 @@ static struct port_buffer *alloc_buf(size_t buf_size) > buf = kmalloc(sizeof(*buf), GFP_KERNEL); > if (!buf) > goto fail; > - buf->buf = kzalloc(buf_size, GFP_KERNEL); > + buf->buf = kmalloc(buf_size, GFP_KERNEL); > if (!buf->buf) > goto free_buf; > buf->len = 0; > -- > 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/