Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752176AbdHJG7A (ORCPT ); Thu, 10 Aug 2017 02:59:00 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:14178 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751702AbdHJG67 (ORCPT ); Thu, 10 Aug 2017 02:58:59 -0400 X-AuditID: cbfec7f4-f79ab6d000003290-60-598c0430a6ae Subject: Re: [PATCH] Introduce dmam_zalloc_coherent() To: Christoph Hellwig , Michael Moese Cc: Robin Murphy , linux-kernel@vger.kernel.org From: Marek Szyprowski Message-id: <6a551a81-748f-e069-8ffd-20ef13e34453@samsung.com> Date: Thu, 10 Aug 2017 08:58:54 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-version: 1.0 In-reply-to: <20170809133705.GA25491@lst.de> Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 7bit Content-language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprCKsWRmVeSWpSXmKPExsWy7djPc7oGLD2RBkd/ClusXH2UyeLyrjls FlNePGeyOPjhCasDi8eaeWsYPXbfbGDz2LXnLYvH501yASxRXDYpqTmZZalF+nYJXBlLHzaz Fjzhqlj05StjA+Nnji5GTg4JAROJWacXMUPYYhIX7q1n62Lk4hASWMoo8WvpQxYI5zOjxKot +9hgOh5eusIOkVjGKDHj8Uko5zmjxNH1j8BmCQuYSnzvWs4KYosIeEg8ObIFrJtZwFXi5AmQ Bk4ONgFDia63XWBxXgE7iVPTnoHZLAKqEmdfXgWbIyoQIzF3QQs7RI2gxI/J91hAbE4BHYkZ 73ayQ8y0knj2r5UVwpaX2LzmLTOELS7R3HoT7AUJgcnsEhu/vGfsYuQAcmQlNh2A+tlF4tP/ bewQtrDEq+NboGwZic6Og0wQdj+jRFOrNoQ9g1Hi3FteCNta4vDxi1B7+SQmb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JJanZqakFqEUwfEwen VANj6OWj5XpzUu5fK8vpT53599QaAdbdJ1ZtnHfJa0WVeP5T8wniU2X/Hfu94vyTmfePqyg4 Odl7X9Iq2bL2wpFFS0xYjvqqvXulk5clV5ps6KY/KeDn4vZ20/ktwp+ZJebPzwi6drXU2+qf /bOTp1iYvhX1ZO1fpGD1f+Ezvse/Iq/qP9ktue6OihJLcUaioRZzUXEiAC+56TvJAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170810065855eucas1p10b5fb770a78e6376914bf943046507da X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRs=?= =?UTF-8?B?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRtT?= =?UTF-8?B?YW1zdW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170809133713epcas3p39562ad3e1f0e54a09c0549d9d3b85cf6 X-RootMTR: 20170809133713epcas3p39562ad3e1f0e54a09c0549d9d3b85cf6 References: <20170808091535.31371-1-michael.moese@men.de> <20170809133705.GA25491@lst.de> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1348 Lines: 30 Hi Christoph, On 2017-08-09 15:37, Christoph Hellwig wrote: > On Tue, Aug 08, 2017 at 11:15:35AM +0200, Michael Moese wrote: >> All memory allocation functions have a pendant for allocating zeroed >> memory, but dmam_alloc_coherent does not have such a pendant. >> However, it is easier to read dmam_zalloc_coherent than passing an extra >> flag or, even worse, see memset() after the allocation. >> This patch adds an inline function dmam_zalloc_coherent(), exactly like >> the implementation of dma_zalloc_coherent(). > I'm a bit worried about the __GFP_ZERO as we have lots of non-kmalloc > implementations of these. But on the other hand we already implement > dma_zalloc_coherent the same way, which means we'd already buggy. > > So I plan to apply this for 4.14, but I also plan to spend some time > to implement all the existin alloc ops to make sure it's going to work > fine. Frankly, since introducing dma_mmap_coherent, dma_alloc_coherent already clears allocated buffers to avoid potential information leak to userspace. There are even drivers that rely on such behavior, see http://lists.infradead.org/pipermail/linux-arm-kernel/2015-April/338804.html Maybe it would make sense to properly document it and then convert dma_zalloc* to standard dma_alloc_* calls? Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland