From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-579947-1517035962-2-8060544289737642920 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no ("Email failed DMARC policy for domain") X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.001, RCVD_IN_DNSWL_MED -2.3, SPF_PASS -0.001, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='140.211.166.136', Host='smtp3.osuosl.org', Country='US', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='us-ascii' X-IgnoreVacation: yes ("Email failed DMARC policy for domain") X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: driverdev-devel-bounces@linuxdriverproject.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1517035961; b=dHEj41EzbgS0CGOX2K1krKWnQDQmfNSkmydw0zbgvp6zSrr DOBDoseLylUx2GZyf6mxmvGcl9nves4k3VZQagsymJC2FqLSaTE2TRp8kHLZ4KAC VEKbH5Q7a3YBH07xrWUTqJHC2r4tBBabElzHVzE49ST8EoJC/StgyCQVadM5CwRO 4rXOtYgwfeAKWe8s5mlVqomSVSQbpeGfeZwaoZedGuMKfFUEVsEo4F5Cxr2J2SCV k7dDd2D+ZENA/HoCL8WIWzBiTqd2Z7038ZD7+do0le/+hA3eZoBr2Cb60PYWR9+s 1NC4UVdLNP7GgqnkKBk7QCMjLDkM4194Wr51H4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:to:references:from:message-id :date:mime-version:in-reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:cc :content-transfer-encoding:content-type:sender; s=arctest; t= 1517035961; bh=fBA1tn/RLaMRDqsb44mgO9bnWa9Pg0xfmPIiH5pzTcU=; b=Z ibHskWrbyaXshcn487AYykN6Jyqvt08xGBnhMGyLFYNt4y7HvVl0sWDvybcXIlWh YV2+jusYPbOdEi7S4viAWtFkYL9t9smpIQbynr+jxNclxUEn4+gON6td8Z+DWXt7 sQQvLC34a5N+cHXOoQhZrs3vZJ3w5GL9QtKuEcuOfm9SPrZlmJaaZZePf6ycbOkn RR297/oLzMD2yMJTdJclffFyJ7dheO5qatX2f7ac5Kul2x+dLM9YgzRvc+CApHCd oYgCvBCQfeCR2wZyT8i05bMK5Hle+G0OejDCvDq9FijWKfowy89sFtnTxjLjG3ee VZaIuIs81NsJfSXuM/Ksw== ARC-Authentication-Results: i=1; mx5.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=fail (p=none,has-list-id=yes,d=none) header.from=redhat.com; iprev=pass policy.iprev=140.211.166.136 (smtp3.osuosl.org); spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org smtp.helo=silver.osuosl.org; x-aligned-from=fail; x-google-dkim=fail (message has been altered; 2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=FQqqH7CX; x-ptr=fail x-ptr-helo=silver.osuosl.org x-ptr-lookup=smtp3.osuosl.org; x-return-mx=pass smtp.domain=linuxdriverproject.org smtp.result=pass smtp_is_org_domain=yes header.domain=redhat.com header.result=pass header_is_org_domain=yes; x-tls=pass version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128 Authentication-Results: mx5.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=fail (p=none,has-list-id=yes,d=none) header.from=redhat.com; iprev=pass policy.iprev=140.211.166.136 (smtp3.osuosl.org); spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org smtp.helo=silver.osuosl.org; x-aligned-from=fail; x-google-dkim=fail (message has been altered; 2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=FQqqH7CX; x-ptr=fail x-ptr-helo=silver.osuosl.org x-ptr-lookup=smtp3.osuosl.org; x-return-mx=pass smtp.domain=linuxdriverproject.org smtp.result=pass smtp_is_org_domain=yes header.domain=redhat.com header.result=pass header_is_org_domain=yes; x-tls=pass version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128 X-Remote-Delivered-To: driverdev-devel@osuosl.org X-Google-Smtp-Source: AH8x224kaZWf87dfJm2anYBogW16TnLb/nOQ/0NRZvHuOzzTHl/E37X0jEc7xsPHIVHiR3EseOBOpA== Subject: Re: [Linaro-mm-sig] [PATCH v3] staging: android: ion: Zero CMA allocated memory To: Chen Feng , Liam Mark , Sumit Semwal References: <5A6BDE11.9070403@hisilicon.com> From: Laura Abbott Message-ID: Date: Fri, 26 Jan 2018 22:52:28 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <5A6BDE11.9070403@hisilicon.com> Content-Language: en-US X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.24 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, Greg KH , Zhuangluan Su , linux-kernel@vger.kernel.org, linaro-mm-sig@lists.linaro.org, "Xiaqing \(A\)" , Dan Carpenter Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On 01/26/2018 06:04 PM, Chen Feng wrote: > > > On 2018/1/27 1:48, Liam Mark wrote: >> Since commit 204f672255c2 ("staging: android: ion: Use CMA APIs directly") >> the CMA API is now used directly and therefore the allocated memory is no >> longer automatically zeroed. >> >> Explicitly zero CMA allocated memory to ensure that no data is exposed to >> userspace. >> >> Fixes: 204f672255c2 ("staging: android: ion: Use CMA APIs directly") >> Signed-off-by: Liam Mark >> --- >> Changes in v2: >> - Clean up the commit message. >> - Add 'Fixes:' >> >> Changes in v3: >> - Add support for highmem pages >> >> drivers/staging/android/ion/ion_cma_heap.c | 17 +++++++++++++++++ >> 1 file changed, 17 insertions(+) >> >> diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c >> index 86196ffd2faf..fa3e4b7e0c9f 100644 >> --- a/drivers/staging/android/ion/ion_cma_heap.c >> +++ b/drivers/staging/android/ion/ion_cma_heap.c >> @@ -21,6 +21,7 @@ >> #include >> #include >> #include >> +#include >> >> #include "ion.h" >> >> @@ -51,6 +52,22 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, >> if (!pages) >> return -ENOMEM; >> >> + 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); > > Here. This way may cause performance latency at mapping-memset-umap page one bye one. > > Take a look at ion_heap_pages_zero. > > Not very critical, arm64 always have linear mapping. > This is under a PageHighMem check so arm64 isn't affected. It's also the same algorithm arm32 dma-mapping.c uses so I'd like to see some data about the performance improvement before we go changing things too much. Thanks, Laura > >> + page++; >> + nr_clear_pages--; >> + } >> + } else { >> + memset(page_address(pages), 0, size); >> + } >> + >> table = kmalloc(sizeof(*table), GFP_KERNEL); >> if (!table) >> goto err; >> > _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel