Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp170748ybe; Sun, 1 Sep 2019 22:54:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQNaSbrBUOn8alxw3qefjXjR+nCRQtuiq6pfPOojeM1QAHdcRIDJ+qoo5d+n5NV4L7NAzS X-Received: by 2002:a17:90a:890c:: with SMTP id u12mr128143pjn.124.1567403652595; Sun, 01 Sep 2019 22:54:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567403652; cv=none; d=google.com; s=arc-20160816; b=h65TIpyLrlsAU/HVQvzvbkh7ZI/puGfFKcwh5/QRtCI889MoJqrLBVbkphcZJKDowv U0ctOA3cF1JZ0iVJS9DBWDVJmqriW/aTnfNLsIEDQNEeXVBJT4quQDG1IgREMM8oWhvT 0/QoRMft+AJCZRI1fknwS0uWqor6EZ8jyP+kEshGUzLGFGe3Eayo12tblXgm0evuyGzG 03fCmJ5nbdUdbwIMvJTYhs9Lw0xDs+sKeJLKr8IXnyhixych3Pl4uvd8Nn63qytswfWa CLGKgy7lVBwsaMqLnMrYf/7hhXqSDh8D2QCk9fF/64JfZEl4c/avr8+TTYo+qImTkpCa g0lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=n5hr5S0QJCg+J27txcfW2jtv7zVdWSzPBOGCkmDhRoA=; b=0zuojJRetok4vtGQYTYD1etrXBLOb0o8kn/y63noIGqQT1cuPiDNbnwsBSUibnjUaj 7UINS3RC5MIi2xGGJjIc4y38wImxxOGO69qVREy0nTNOeNxmB5vFHKfkO+ocDjd3i69V VkKKxI3ndbi+NeXwbBgzjBfqg0dMCxebtl4PcXS2imnveXFBV4Aytq5IVax6aoQZHTz2 ue0Uh3i0csve4Tb+FihiCZgI5P/qn4t6wP5SB07MLUm3mzS6p9q3h9PgKnl1z8JRrQdM paIEpfKuxgxuVyw+81HP4NdwSIjzumbdPsLlfTlUW5i/qjgav0E6EOA437Yjz90zY8L1 J+lA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g28si10774163pgl.84.2019.09.01.22.53.57; Sun, 01 Sep 2019 22:54:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729554AbfIBF2y (ORCPT + 99 others); Mon, 2 Sep 2019 01:28:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48324 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726230AbfIBF2y (ORCPT ); Mon, 2 Sep 2019 01:28:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F00BF307CDE7; Mon, 2 Sep 2019 05:28:53 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-95.ams2.redhat.com [10.36.116.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 579F55D6B7; Mon, 2 Sep 2019 05:28:53 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3E46B16E08; Mon, 2 Sep 2019 07:28:52 +0200 (CEST) Date: Mon, 2 Sep 2019 07:28:52 +0200 From: Gerd Hoffmann To: David Riley Cc: dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, David Airlie , Daniel Vetter , Gurchetan Singh , =?utf-8?B?U3TDqXBoYW5l?= Marchesin , linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/virtio: Use vmalloc for command buffer allocations. Message-ID: <20190902052852.vqejjqrib6tvv2v5@sirius.home.kraxel.org> References: <20190829212417.257397-1-davidriley@chromium.org> <20190830060857.tzrzgoi2hrmchdi5@sirius.home.kraxel.org> <20190830111605.twzssycagmjhfa45@sirius.home.kraxel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 02 Sep 2019 05:28:54 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 30, 2019 at 10:49:25AM -0700, David Riley wrote: > Hi Gerd, > > On Fri, Aug 30, 2019 at 4:16 AM Gerd Hoffmann wrote: > > > > Hi, > > > > > > > - kfree(vbuf->data_buf); > > > > > + kvfree(vbuf->data_buf); > > > > > > > > if (is_vmalloc_addr(vbuf->data_buf)) ... > > > > > > > > needed here I gues? > > > > > > > > > > kvfree() handles vmalloc/kmalloc/kvmalloc internally by doing that check. > > > > Ok. > > > > > - videobuf_vmalloc_to_sg in drivers/media/v4l2-core/videobuf-dma-sg.c, > > > assumes contiguous array of scatterlist and that the buffer being converted > > > is page aligned > > > > Well, vmalloc memory _is_ page aligned. > > True, but this function gets called for all potential enqueuings (eg > resource_create_3d, resource_attach_backing) and I was concerned that > some other usage in the future might not have that guarantee. The vmalloc_to_sg call is wrapped into "if (is_vmalloc())", so this should not be a problem. > > sg_alloc_table_from_pages() does alot of what you need, you just need a > > small loop around vmalloc_to_page() create a struct page array > > beforehand. > > That feels like an extra allocation when under memory pressure and > more work, to not gain much -- there still needs to be a function that > iterates through all the pages. But I don't feel super strongly about > it and can change it if you think that it will be less maintenance > overhead. Lets see how vmalloc_to_sg looks like when it assumes page-aligned memory. It's probably noticeable shorter then. cheers, Gerd