Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp734463pxb; Wed, 27 Jan 2021 21:14:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJy49frKXLjXSHPUSCFR2BNl1tXUXq2cI14nhpQRxG9ueYNjN/sjjuOMCrXTykfgeA7Kf4Rp X-Received: by 2002:a05:6402:34c5:: with SMTP id w5mr12268926edc.65.1611810894526; Wed, 27 Jan 2021 21:14:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611810894; cv=none; d=google.com; s=arc-20160816; b=hvQIF1uXnSyzS5iaejQsMtIVH8cX6N8ljm2Od+bqCVPIaIrcJ/K4duwMdQSzaICr1M 87SIH6qRpeefYd7vi210vNYOT6/Bnhf7aKHCEzaFFEuqcWVdgSvG0StnhfreI2WQfggV gThm8/1PYM18tVssF2CmHtgOx4K1fd05squvSMKfR/DFElOg3ivulhtimvpvTbWoXCzn oCdibuRpiUSzy5xgp1KwvJXrTOly74yS2Jh6Y3bGs72zN1vDH+nhDl81TM8KT+p6uiFr +hg+Pgq/6xncDiYQ2cbEOpeb+aWhzskK5kPbeHr2U8Qrr3a1udD5TbQzsEv3Zu9lchoB ggbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=sbySH8XGPeHypTQ5quW2/0H5BDl8PiMEsgfEVwoeeI4=; b=RVVKkAqwRIPf6ID855QsWnrdteUmyXXx0XQAbe+c7gyzexcZB7t33eGVBgS1FcznOu 5HLskNWvZOeJBSjIHaOhOJS5BX1vMXddA7BBqw69rYQIpjtKmTCQ/RcGuDq1ubjwiRSP YTtrQFvBhfMdGVoZQ5YVgiC1fxxFxw7p420vlMNEnmd5vzQHPDUydLACRZf4CPjkwSnJ +IqZlzbys5e3fHxJdhjr0HDWEP8MW+5QYJxbZ0JDwl2v7W57pE+YYd5ny2ULBed1rcKM yFwti2VK8IRWn7IyPfONTHUnDcZk+fVu2HHrYS/A5OJUJNcCq2fonC645K8q3tmoGsK6 43Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="v0WZgt/3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a8si2152158edv.386.2021.01.27.21.14.29; Wed, 27 Jan 2021 21:14:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="v0WZgt/3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229785AbhA1FLL (ORCPT + 99 others); Thu, 28 Jan 2021 00:11:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbhA1FLK (ORCPT ); Thu, 28 Jan 2021 00:11:10 -0500 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 973EBC061756 for ; Wed, 27 Jan 2021 21:10:29 -0800 (PST) Received: by mail-lj1-x22e.google.com with SMTP id v15so1834293ljk.13 for ; Wed, 27 Jan 2021 21:10:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sbySH8XGPeHypTQ5quW2/0H5BDl8PiMEsgfEVwoeeI4=; b=v0WZgt/3pzp9gQrGDilRFIBE1VUrEj5i/gJgcppmH3N0+htGlb9glkmXh3fwsYmhuP R6ECXFmWEz2+t1PvqYqX/zbAXF8r4adCx76XaHJ58SkfJBZv1a37Opmw51U3trAcpIVa lieq/+F1l/t+XzOMWdb4kHGdt5Zb9iNi1y5n6hypaEiM4Xg6SBpEWhfMbjaazGgPAsep QxaQmDK+zITPVJazdV73+6W/LKHoL0yqrYMQFOM5kO0dWKCMatbPTDyu7tztCEyGu1it Zb4/Tx7o02upoGqTw3eVhy0wLaOnB/J6f3dENS44UJtFqQnTtCt2tnNREYGnxahSLvBe e26A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sbySH8XGPeHypTQ5quW2/0H5BDl8PiMEsgfEVwoeeI4=; b=GdVn4mitBpZvOkBR5Bo8utoN29J3aCaC39JB2KFLoqDVe0fDWHG37tJW2PA3SVMe+X F9X1S4jC5Z/5tpvk7MBKXQGBgeABSyYna0QjK/DCH52/dBMuB+EaNhvGDjMQronxCE+m I4HicZCl0GcSPc5BoinRUAGHHjdHfnWosd4wtjmuwIbkU+jjhCIgVf82lvPglGeEQ5Zg o/QVTSX4A/Wzq6nS0XSX8v32Z/iWhZ3/nEVQRLy3eUMtZYov77fFaIhiERjVso/Lz5ir n+u4/4EoT0NPVl8bw+gKzjI2YIagNPijIw3hqAwmUN0TLb0/WDJAu1ZExw29c02lvuEl uwGQ== X-Gm-Message-State: AOAM533JGdP6/zLF6BgLw0flSkZkcq4kP9HlvVCZ1wkd35qJFdUEmCIA UVF2WU7AEPFClHVGtraMK58GmnUMvANAXzfKGTITjQ== X-Received: by 2002:a2e:3018:: with SMTP id w24mr7835128ljw.333.1611810627528; Wed, 27 Jan 2021 21:10:27 -0800 (PST) MIME-Version: 1.0 References: <20210123034655.102813-1-john.stultz@linaro.org> <20210123034655.102813-2-john.stultz@linaro.org> In-Reply-To: From: John Stultz Date: Wed, 27 Jan 2021 21:10:15 -0800 Message-ID: Subject: Re: [PATCH v2 2/3] dma-buf: system_heap: Add pagepool support to system heap To: Daniel Mentz Cc: lkml , Daniel Vetter , Sumit Semwal , Liam Mark , Chris Goldsworthy , Laura Abbott , Brian Starkey , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , =?UTF-8?Q?=C3=98rjan_Eide?= , Robin Murphy , Ezequiel Garcia , Simon Ser , James Jones , linux-media , dri-devel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 27, 2021 at 12:21 PM Daniel Mentz wrote: > > On Fri, Jan 22, 2021 at 7:47 PM John Stultz wrote: > > +static int system_heap_clear_pages(struct page **pages, int num, pgprot_t pgprot) > > +{ > > + void *addr = vmap(pages, num, VM_MAP, pgprot); > > + > > + if (!addr) > > + return -ENOMEM; > > + memset(addr, 0, PAGE_SIZE * num); > > + vunmap(addr); > > + return 0; > > +} > > I thought that vmap/vunmap are expensive, and I am wondering if > there's a faster way that avoids vmap. > > How about lifting this code from lib/iov_iter.c > static void memzero_page(struct page *page, size_t offset, size_t len) > { > char *addr = kmap_atomic(page); > memset(addr + offset, 0, len); > kunmap_atomic(addr); > } > > Or what about lifting that code from the old ion_cma_heap.c > > if (PageHighMem(pages)) { > unsigned long nr_clear_pages = nr_pages; > struct page *page = pages; > > while (nr_clear_pages > 0) { > void *vaddr = kmap_atomic(page); > > memset(vaddr, 0, PAGE_SIZE); > kunmap_atomic(vaddr); > page++; > nr_clear_pages--; > } > } else { > memset(page_address(pages), 0, size); > } Though, this last memset only works since CMA is contiguous, so it probably needs to always do the kmap_atomic for each page, right? I'm still a little worried if this is right, as the current implementation with the vmap comes from the old ion_heap_sglist_zero logic, which similarly tries to batch the vmaps 32 pages at at time, but I'll give it a try. thanks -john