From patchwork Wed Apr 5 01:29:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunhui Li X-Patchwork-Id: 9663623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 89C5B6021C for ; Wed, 5 Apr 2017 10:02:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FC58285A8 for ; Wed, 5 Apr 2017 10:02:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64AD3285AB; Wed, 5 Apr 2017 10:02:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 53210285B1 for ; Wed, 5 Apr 2017 10:02:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Lv0QVm3SHynPtUWUfXzVhS92t+fKZvo/WLR4Ayyj59Q=; b=soGBoLYdRSnTED 3lN2/SDhfBiv3HfLBKaWZeQtFlpNq3YRte6FQ4QNaeX0z5ZmrsGn7d+5l6ZIjIz8vBMNDx5OObbPs nf1GC1A/GpoM/EXDwrZY8gQbhVsFjQqEJXuhy4lRfl7QOjCBci5AhZjbQNmQffI1icQuZX33829rx OrJ03y2kLGar4jrCnUImEUyeMIT65hwUePeIhPBG8SQ20npSgEJiGvyBNP9qGvOLiYHwHEMgYsckK nNr2RHabhhTnm3+vo3KSiWY+glY3wLK6cb80qgZqB1GB7iBPhM1hF9ESaXoZMOdlCnlHofVkkHY29 ip1TYVoCdB4nlxzFdN1g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cvhm5-0003CS-B7; Wed, 05 Apr 2017 10:02:49 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cvZqG-0000ds-DG; Wed, 05 Apr 2017 01:34:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:Message-ID: Date:Subject:CC:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0C3rgGDX6bRk65+lUgEXTBARFCMuNL/abFexhyNPqdY=; b=SC046oiEcSaoXvle2ybKq4t4bE 0yNb1Fjz3S9a1av1g8VqSMjzrpIhuvwxWIFdTfxj7Sak9OMp24IC7MDwObxUCFJM/xGt99UVoQ2Ja VX5u3Sm+s05ziHqKMRXyBH3vVo4x7VLL4ik+At5RB1Z4qZPpHZxVcruiGpNqTNyFyRl5i1HJXRoTj n7vDuBRfF1D3fkQ2VXYKha3ihcmdMfzBvhyhMjD4agtsry6d6OQCes9k27c1Pvdsv6wzFOlbOrWqV 7nqb6g26JR0mEyGN6QIsjgTawNrGnYy0i26Yh7XuGR01FVFtY1/Ust05sLogh5aCwA6NudqSEwWvG Odz1yZDQ==; Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cvZq6-0006WR-1q; Wed, 05 Apr 2017 01:34:26 +0000 Received: from mtkhts07.mediatek.inc [(172.21.101.69)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1949180609; Wed, 05 Apr 2017 09:29:09 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkhts07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.266.1; Wed, 5 Apr 2017 09:29:07 +0800 From: Chunhui Li To: Alexander Viro , Matthias Brugger Subject: [PATCH] fs: seq_buf_alloc use vmalloc for high order allocations Date: Wed, 5 Apr 2017 09:29:04 +0800 Message-ID: <20170405012904.1469-1-chunhui.li@mediatek.com> X-Mailer: git-send-email 2.9.2 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170404_213426_315009_8AE3EEC6 X-CRM114-Status: GOOD ( 14.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wsd_upstream@mediatek.com, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, "chunhui.li" , linux-fsdevel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: "chunhui.li" For high order allocations, use vmalloc() to reduce physically contiguous memory consumption and avoid memory fragmentation issues Signed-off-by: chunhui.li --- fs/seq_file.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/fs/seq_file.c b/fs/seq_file.c index ca69fb9..4527e79 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -26,19 +26,17 @@ static void seq_set_overflow(struct seq_file *m) static void *seq_buf_alloc(unsigned long size) { void *buf; - gfp_t gfp = GFP_KERNEL; /* - * For high order allocations, use __GFP_NORETRY to avoid oom-killing - - * it's better to fall back to vmalloc() than to kill things. For small - * allocations, just use GFP_KERNEL which will oom kill, thus no need - * for vmalloc fallback. - */ + * For high order allocations, use vmalloc() to reduce physically + * contiguous memory usage and avoid memory fragmentation issue. + * For small allocations, just use GFP_KERNEL + * which will oom kill, thus no need for vmalloc fallback. + */ if (size > PAGE_SIZE) - gfp |= __GFP_NORETRY | __GFP_NOWARN; - buf = kmalloc(size, gfp); - if (!buf && size > PAGE_SIZE) buf = vmalloc(size); + else + buf = kmalloc(size, GFP_KERNEL); return buf; }