Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753410AbcL3G1P (ORCPT ); Fri, 30 Dec 2016 01:27:15 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:56412 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750984AbcL3G1O (ORCPT ); Fri, 30 Dec 2016 01:27:14 -0500 MIME-version: 1.0 Content-type: text/plain; charset=utf-8 X-AuditID: b6c32a3c-f79646d000004d82-1f-5865fe402182 Content-transfer-encoding: 8BIT Subject: Re: [PATCH] mm: cma: print allocation failure reason and bitmap status To: Michal Hocko Cc: gregkh@linuxfoundation.org, akpm@linux-foundation.org, labbott@redhat.com, mina86@mina86.com, m.szyprowski@samsung.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com From: Jaewon Kim Message-id: <5865FE6D.5050500@samsung.com> Date: Fri, 30 Dec 2016 15:27:57 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 In-reply-to: <20161229094335.GH29208@dhcp22.suse.cz> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGJsWRmVeSWpSXmKPExsWy7bCmvq7Dv9QIg77f7BZz1q9hs2hevJ7N onvzTEaLlXt+MFlc3jWHzeLemv+sFmuP3GW3eP1tGbPFguMtrA6cHjtn3WX32LSqk81j06dJ 7B4nZvxm8dg/dw27x7o/r5g83u+7yubRt2UVo8fnTXIBnFGpNhmpiSmpRQqpecn5KZl56bZK 3sHxzvGmZgaGuoaWFuZKCnmJuam2Si4+AbpumTlARyoplCXmlAKFAhKLi5X07WyK8ktLUhUy 8otLbJWiDQ2N9AwNzPWMjIz0TMxjrYxMgUoSUjMWPO9nL1goX/H83DKWBsZvEl2MnBwSAiYS 367+ZIawxSQu3FvPBmILCexglDiyqqKLkQvIbmeSuHOuiwmmoe/VBkaIxBxGia8TJ7OAJHgF BCV+TL4HZHNwMAv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 4silbAhTXWLKlFyI8oeMEuubrzCBlAsL+EssuLUJzBYRUJFY33eHHaJoIpNE7+V3rCAOs8AJ RonNe4+zgFSxCWhLvF8wiRVimZbE/HnLwOIsAqoSe75fBrNFBSIkVq+7xgxicwJdvedmJ8sE RqAzEe6bhXDfLIT7FjAyr2KUSC1ILihOSs81zEst1ytOzC0uzUvXS87P3cQIjs5nUjsYD+5y P8QowMGoxMP7oyw1Qog1say4MvcQowQHs5IIb9ZfoBBvSmJlVWpRfnxRaU5q8SFGU6ATJzJL iSbnAxNHXkm8oYm5ibmxgYW5paWJkZI4b+PsZ+FCAumJJanZqakFqUUwfUwcnFINjMemOPuE HvJYWdlyt0W7eD1f4CZW/oMqZ5f7R0+a9PHL9wr3ny5GDgGe3tPC9szbJNNbKS4nN7voj/eT Jydv+Ozik152Zso+nSK/s4numXEz7yaF+h3Q7L522+vCTvVZRTyT7cV2fZdO+e7tcDZwXbLN xycLmR+kuc82sN4cqhGe/64y3O3yUiWW4oxEQy3mouJEANGqWzHkAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161230062711epcas1p2b577514f2f6a5a095784b89a6e30a1b2 X-Msg-Generator: CA X-Sender-IP: 203.254.230.26 X-Local-Sender: =?UTF-8?B?6rmA7J6s7JuQG1N5c3RlbSBTL1fqsJzrsJwy6re466O5KA==?= =?UTF-8?B?66y07ISgKRvsgrzshLHsoITsnpAbUzUo7LGF7J6EKS/ssYXsnoQ=?= X-Global-Sender: =?UTF-8?B?SmFld29uIEtpbRtTeXN0ZW0gUy9XIFImRCBHcm91cCAyG1Nh?= =?UTF-8?B?bXN1bmcgRWxlY3Ryb25pY3MbUzUvU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG1RFTEUbQzEwRDkxMjI=?= CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-HopCount: 7 X-CMS-RootMailID: 20161229022722epcas5p4be0e1924f3c8d906cbfb461cab8f0374 X-RootMTR: 20161229022722epcas5p4be0e1924f3c8d906cbfb461cab8f0374 References: <1482978482-14007-1-git-send-email-jaewon31.kim@samsung.com> <20161229091449.GG29208@dhcp22.suse.cz> <5864D6CE.7070001@samsung.com> <20161229094335.GH29208@dhcp22.suse.cz> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3900 Lines: 103 On 2016년 12월 29일 18:43, Michal Hocko wrote: > On Thu 29-12-16 18:26:38, Jaewon Kim wrote: >> >> On 2016년 12월 29일 18:14, Michal Hocko wrote: >>> On Thu 29-12-16 11:28:02, Jaewon Kim wrote: >>>> There are many reasons of CMA allocation failure such as EBUSY, ENOMEM, EINTR. >>>> This patch prints the error value and bitmap status to know available pages >>>> regarding fragmentation. >>>> >>>> This is an ENOMEM example with this patch. >>>> [ 11.616321] [2: Binder:711_1: 740] cma: cma_alloc: alloc failed, req-size: 256 pages, ret: -12 >>>> [ 11.616365] [2: Binder:711_1: 740] number of available pages: 4+7+7+8+38+166+127=>357 pages, total: 2048 pages >>> Could you be more specific why this part is useful? >> Hi >> Without this patch we do not know why CMA allocation failed. > Yes, I understand the first part > >> Additionally in case of ENOMEM, with bitmap status we can figure out that > The code doesn't seem to check for ENOMEM though Yes actually I wanted to look both ENOMEM case and EBUSY case. Even in EBUSY case, we can look how much available pages existed, but all failed on those region because of EBUSY. We may not need EINTR case, but I hope to look. > >> if it is too small CMA region issue or if it is fragmentation issue. > then please describe that in the changelog. If I got it right the above > would tell us that the fragmentation is the problem, right? Yes fragmentation can be A problem, but bitmap status will explain EBUSY case too as I explained above. > >>> >>>> Signed-off-by: Jaewon Kim >>>> --- >>>> mm/cma.c | 29 ++++++++++++++++++++++++++++- >>>> 1 file changed, 28 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/mm/cma.c b/mm/cma.c >>>> index c960459..535aa39 100644 >>>> --- a/mm/cma.c >>>> +++ b/mm/cma.c >>>> @@ -369,7 +369,7 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align) >>>> unsigned long start = 0; >>>> unsigned long bitmap_maxno, bitmap_no, bitmap_count; >>>> struct page *page = NULL; >>>> - int ret; >>>> + int ret = -ENOMEM; >>>> >>>> if (!cma || !cma->count) >>>> return NULL; >>>> @@ -427,6 +427,33 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align) >>>> trace_cma_alloc(pfn, page, count, align); >>>> >>>> pr_debug("%s(): returned %p\n", __func__, page); >>>> + >>>> + if (ret != 0) { >>>> + unsigned int nr, nr_total = 0; >>>> + unsigned long next_set_bit; >>>> + >>>> + pr_info("%s: alloc failed, req-size: %zu pages, ret: %d\n", >>>> + __func__, count, ret); >>>> + mutex_lock(&cma->lock); >>>> + printk("number of available pages: "); > I guess you want pr_info (or maybe pr_debug) here Thank you I will change as you and Michal Nazarewichz commented. > >>>> + start = 0; >>>> + for (;;) { >>>> + bitmap_no = find_next_zero_bit(cma->bitmap, cma->count, start); >>>> + next_set_bit = find_next_bit(cma->bitmap, cma->count, bitmap_no); >>>> + nr = next_set_bit - bitmap_no; >>>> + if (bitmap_no >= cma->count) >>>> + break; >>>> + if (nr_total == 0) >>>> + printk("%u", nr); >>>> + else >>>> + printk("+%u", nr); > pr_cont > >>>> + nr_total += nr; >>>> + start = bitmap_no + nr; >>>> + } >>>> + printk("=>%u pages, total: %lu pages\n", nr_total, cma->count); > pr_cont > >>>> + mutex_unlock(&cma->lock); >>>> + } >>>> + >>>> return page; >>>> } >>>> >>>> -- >>>> 1.9.1 >>>> >>>> -- >>>> To unsubscribe, send a message with 'unsubscribe linux-mm' in >>>> the body to majordomo@kvack.org. For more info on Linux MM, >>>> see: http://www.linux-mm.org/ . >>>> Don't email: email@kvack.org >> -- >> To unsubscribe, send a message with 'unsubscribe linux-mm' in >> the body to majordomo@kvack.org. For more info on Linux MM, >> see: http://www.linux-mm.org/ . >> Don't email: email@kvack.org