Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752713AbcL2J00 (ORCPT ); Thu, 29 Dec 2016 04:26:26 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:46526 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752110AbcL2J0X (ORCPT ); Thu, 29 Dec 2016 04:26:23 -0500 MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 X-AuditID: b6c32a3c-f79646d000004d82-fe-5864d6a391a7 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: <5864D6CE.7070001@samsung.com> Date: Thu, 29 Dec 2016 18:26:38 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 In-reply-to: <20161229091449.GG29208@dhcp22.suse.cz> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGJsWRmVeSWpSXmKPExsWy7bCmnu7iaykRBlNaRC3mrF/DZtG8eD2b RffmmYwWK/f8YLK4vGsOm8W9Nf9ZLdYeuctu8frbMmaLBcdbWB04PXbOusvusWlVJ5vHpk+T 2D1OzPjN4rF/7hp2j3V/XjF5vN93lc2jb8sqRo/Pm+QCOKNSbTJSE1NSixRS85LzUzLz0m2V vIPjneNNzQwMdQ0tLcyVFPISc1NtlVx8AnTdMnOAjlRSKEvMKQUKBSQWFyvp29kU5ZeWpCpk 5BeX2CpFGxoa6RkamOsZGRnpmZjHWhmZApUkpGb0n33DXnBHtGL+o8mMDYw9gl2MnBwSAiYS TX1/GSFsMYkL99azdTFycQgJ7GCU2LFvLSOE084ksfLySmaYjhkHTjFBJJYzSvR/nMUEkuAV EJT4Mfk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ISvyYfA/I5uBgFpCX OHIpGyTMLKAuMWneImaI+oeMEmuO3gUbJCzgL7Hg1iYwW0RARWJ93x12iKITjBIPVz1iAnGY QZzNe4+DbWAT0JZ4v2ASK8gGXgEtid3bfEHCLAKqEm9e/2UFsUUFIiRWr7vGDGJzAl29bMU0 5gmMArOQ3DcL4b5ZSO5bwMi8ilEitSC5oDgpPdcwL7Vcrzgxt7g0L10vOT93EyM4Pp9J7WA8 uMv9EKMAB6MSD6+ETEqEEGtiWXFl7iFGCQ5mJRFe5ktAId6UxMqq1KL8+KLSnNTiQ4ymQDdO ZJYSTc4Hpo68knhDE3MTc2MDC3NLSxMjJXHextnPwoUE0hNLUrNTUwtSi2D6mDg4pRoYlzXw Tb0nLiSp/LxBTn9K6+qFO70NHsvXtdy1+P3jcnH1vvms97fF3PIufXHEcWaPytvsGYc2yr7c vIih0Pej5HO9CafY/bQElHRU/t+/7Xnj8efHn2TeiCyZZGUa3VzkWeh+QG5WYEhb/zyfJYbv LkjbnijdInlu3qPVmyte2IpZX5hn8+WyvhJLcUaioRZzUXEiAJaPkW3lAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161229092555epcas1p15a59b9e8a4bd427d32f0ee114c2641fc 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> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2705 Lines: 77 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. Additionally in case of ENOMEM, with bitmap status we can figure out that if it is too small CMA region issue or if it is fragmentation issue. > >> 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: "); >> + 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); >> + nr_total += nr; >> + start = bitmap_no + nr; >> + } >> + printk("=>%u pages, total: %lu pages\n", nr_total, cma->count); >> + 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