Received: by 10.223.164.202 with SMTP id h10csp262829wrb; Tue, 14 Nov 2017 00:44:56 -0800 (PST) X-Google-Smtp-Source: AGs4zMZiLe/QSecN9hB+qjiYTejs6DTbQhSAuvAXS0Ga0x5JXMXbZZHZVePga4Et7NAQC4efPe0n X-Received: by 10.84.245.147 with SMTP id j19mr11636895pll.300.1510649096553; Tue, 14 Nov 2017 00:44:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510649096; cv=none; d=google.com; s=arc-20160816; b=sXQusX6glgCz4HyRiaP+/B/bbYutwO/TfYXWwyionTDSqvbD/IqBbgTxTf+9KLkki5 rwmBt/9g3/hfObyRaKNpCYCIXzoN0f1L9l5DbWu5NfTA+uaLnLIyi45N7JQP1+U6Vfm4 RgZdQJ2/TNRbOnxUkQNaklm3Lu2KRTyuwHTmaTkZsJOMNkPsAnsgbOp0yNUpYAnduW1a Fdfz5nGWM6yA2Deoxdx/fssEF2uB2Gyd3s4FYYkv5baqGiFieK6QQNA8TNBWAnN9MGen xqC0vyEFyRuuDZKFPrVzcTPFsb3fRqeAATVJ2JGfFAtbQWeASM5d/7neU0k15yaHa4lo Se6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:dlp-filter:cms-type:message-id :date:subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=B5K5qOnIk3gK/nG/cjbSGkcxo6BsItqDkUYA+j5dKoo=; b=AMA5nvUGURN/0iHUIKf/2gPAF1YVSZLhPm/JIy6xa2Q503nXehns8hH40to5OW1a8W d02ClfAQo6V3Sw8+3lC9PbZJ4eieDPV8X6YLAFvLQ1I7gCgbIb7JOu5SNSniQvyyK36p xh+3cznIzmZwe0b5+jUKJGh40MjaCUUzLElfllQ0OWW3qsORBCthcOHJmDFYY3h1EVEF anG8fomNKxo/plHV5AO8NX0muEEnEcRA2jzl07J/uX7KejfcxRUzIyp6eX3zHXbvNh+R EsLUgL7Loty/4YTf2kLlUHq2WkEEMRvRtgkd/xqsPEQGl7UkDhB8UzUGVZd3+C/zKZuf 0Xqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=qok0NSct; 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=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6si15213223pgf.759.2017.11.14.00.44.43; Tue, 14 Nov 2017 00:44:56 -0800 (PST) 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; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=qok0NSct; 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=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752360AbdKNImp (ORCPT + 88 others); Tue, 14 Nov 2017 03:42:45 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:12947 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751466AbdKNImh (ORCPT ); Tue, 14 Nov 2017 03:42:37 -0500 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20171114084235epoutp0216c54a470b1e7b9104f8c64e0056736f~25ziiR8cf3032230322epoutp02I; Tue, 14 Nov 2017 08:42:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20171114084235epoutp0216c54a470b1e7b9104f8c64e0056736f~25ziiR8cf3032230322epoutp02I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1510648955; bh=B5K5qOnIk3gK/nG/cjbSGkcxo6BsItqDkUYA+j5dKoo=; h=From:To:Cc:Subject:Date:References:From; b=qok0NSctbGsSS/KXAMMcz2kUsV/MHj+V4mcwokLpOWJ7HiEqxo9/bMV73nBzPPHGI b+hgsfgNs/BUQHfatg+vjt0U+YYRs51JobIm6jOcatP6d1fcPg66svXtG0RJCK6mb4 qPorSjxKyxIZ5sF0PCXhDaCvqwJM69Bvy/Crd55c= Received: from epsmges2p1.samsung.com (unknown [182.195.40.92]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20171114084235epcas1p45eb3c2fdd259f94556cac015868a7636~25ziSO0AM0338003380epcas1p4X; Tue, 14 Nov 2017 08:42:35 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id CA.8A.04393.B7CAA0A5; Tue, 14 Nov 2017 17:42:35 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20171114084234epcas2p44ac00494b49aa798f709c5bbdf92127a~25ziCb7B72864728647epcas2p4Z; Tue, 14 Nov 2017 08:42:34 +0000 (GMT) X-AuditID: b6c32a45-333ff70000001129-65-5a0aac7bde66 Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 99.E7.03859.A7CAA0A5; Tue, 14 Nov 2017 17:42:34 +0900 (KST) Received: from jaewon-linux.165.213.246.161 ([10.253.100.37]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OZE004Q4G6QZ810@mmp1.samsung.com>; Tue, 14 Nov 2017 17:42:34 +0900 (KST) From: Jaewon Kim To: hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com, gregkh@linuxfoundation.org, iommu@lists.linux-foundation.org Cc: akpm@linux-foundation.org, mhocko@suse.com, vbabka@suse.cz, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, Jaewon Kim Subject: [RFC PATCH] drivers: base: dma-coherent: find free region without alignment Date: Tue, 14 Nov 2017 17:42:29 +0900 Message-id: <20171114084229.13512-1-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.13.0 X-Brightmail-Tracker: H4sIAAAAAAAAAzWSa0hTYRjHez3bOdtycZhWbwa1TjcyXDunzR1Nu9CFQxeUipCFrJOepuQu 7EzJilqKIjOttA+mS4Q+VDYZTtGZlTSvlFlmRoKWRUVIN2ZlaGbbjn37/d/n/3+fh4dHgiie i2Mk2WY7ZzOzOQQqE7V0bqDjzrhlevVwDUa7PG6ULrzhQenbd7oj6LqOLXRp0zVAl32biKCH 7rpQ+rV7Tkw3dI1h9Jvy7fTD7+/FdM2FcrA9knHXugHTVj2GMd5ABcb0Vc2ImI7rboypfHUT MO0jDpQpb64HjKd5WMT013VhzKR3RepCPZeUxbGZnE3JmTMsmdlmYzKx75Bhp0EbrybjyARa RyjNrIlLJnbtT43bk50TnJ1Q5rE5ucGnVJbniU1bk2yWXDunzLLw9mTiKElSKlKtU1EUpdLo 0hMpbdByjMsae/tFZO1ZdMo3Mi1ygJmFTiCRQFwD/T15TiCTKHAfgKPVvYggpgC8Vz8e4QTS sOlRaaVYKLQDOODrBoKYA/D7yM+wC8U3wm91FeIQR+Pn4NdKBxoyIXgTgEW/fmChQhR+BE64 XoIQi/C1cPxqIRJiOZ4MZwKFqNBuJXwxfUkUCkO8C4X9/oL5OXbBx6NOscBRcKK3GRN4OfxY 3wiEQCmAFxs984GSoBjPFngzDExOhjsj+CJY0jmLCRuQw5JihWBhYNVf7/yfO+CT9w3hgRR4 Oqx90YRcBsvqwIJ6sISz8iYjx1NWUsWzJj7XbFRlWExeEL6n2N0+UDWw3w9wCSAi5Z8GpXqF mM3j801+ACUIES1vq5bpFfJMNv80Z7M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S-MailID: 20171114084234epcas2p44ac00494b49aa798f709c5bbdf92127a X-Msg-Generator: CA CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20171114084234epcas2p44ac00494b49aa798f709c5bbdf92127a X-RootMTR: 20171114084234epcas2p44ac00494b49aa798f709c5bbdf92127a References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org dma-coherent uses bitmap API which internally consider align based on the requested size. Depending on some usage pattern, using align, I think, may be good for fast search and anti-fragmentation. But with the align, an allocation may be failed. This is a example, total size is 30MB, only few memory at front is being used, and 9MB is being requsted. Then 9MB will be aligned to 16MB. The first try on offset 0MB will be failed because of others already using. The second try on offset 16MB will be failed because of ouf of bound. So if the align is not necessary on dma-coherent, this patch removes the align policy to allow allocation without increasing the total size. Signed-off-by: Jaewon Kim --- drivers/base/dma-coherent.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index 744f64f43454..b86a96d0cd07 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c @@ -162,7 +162,7 @@ EXPORT_SYMBOL(dma_mark_declared_memory_occupied); static void *__dma_alloc_from_coherent(struct dma_coherent_mem *mem, ssize_t size, dma_addr_t *dma_handle) { - int order = get_order(size); + int nr_page = PAGE_ALIGN(size) >> PAGE_SHIFT; unsigned long flags; int pageno; void *ret; @@ -172,9 +172,11 @@ static void *__dma_alloc_from_coherent(struct dma_coherent_mem *mem, if (unlikely(size > (mem->size << PAGE_SHIFT))) goto err; - pageno = bitmap_find_free_region(mem->bitmap, mem->size, order); - if (unlikely(pageno < 0)) + pageno = bitmap_find_next_zero_area(mem->bitmap, mem->size, 0, + nr_page, 0); + if (unlikely(pageno >= mem->size)) { goto err; + bitmap_set(mem->bitmap, pageno, nr_page); /* * Memory was found in the coherent area. -- 2.13.0 From 1584154491000994986@xxx Wed Nov 15 17:37:31 +0000 2017 X-GM-THRID: 1584154491000994986 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread