From patchwork Wed Apr 26 03:08:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunhui Li X-Patchwork-Id: 9700197 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 F1F69603F7 for ; Wed, 26 Apr 2017 03:10:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E19D428464 for ; Wed, 26 Apr 2017 03:10:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D65602847F; Wed, 26 Apr 2017 03:10:23 +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 6F25428464 for ; Wed, 26 Apr 2017 03:10:23 +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=rXnjBPvlHyv9jb9zkbqNOyAgRX/yLvLFxth3TH0BBg8=; b=NtdcZo+5nXGVoG AdgdSWEfOzEhXRqXfM+cwJvdlREHFfm9bb+cYsn10/YAk2R5JoOurOUSb4C9lFdoSTWq3AmqynGf/ wzDc/LwGSvOJf/G2iT+UucyaiWZd6jglBiI1jlNW5fs/Eld6Q1zh94sNCJ96EZwgP0oHzpVsu/21R +U4/5eAqHyPc/VAAHlD9B9YivsQp806c0GwRiPSoLXKfcPIoiGUVSbNAJ02Qpi1fb6pG+8K8lYBzn ffwEeY+HJCMuy2nUcphtjRDSyznpTijcLZGUR1RQrnoPBL2M5Nd34ZZQLVU+lx44plytZ0WuUn7Mj SmUAlXUhGSloUeW0U2WQ==; 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 1d3DLE-0003xK-Ah; Wed, 26 Apr 2017 03:10:08 +0000 Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d3DKm-0003gc-Q0; Wed, 26 Apr 2017 03:09:43 +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 563965360; Wed, 26 Apr 2017 11:09:03 +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, 26 Apr 2017 11:09:00 +0800 From: Chunhui Li To: Alexander Viro , Matthias Brugger Subject: [PATCH] fs: seq_buf_alloc use vmalloc for high order allocations Date: Wed, 26 Apr 2017 11:08:59 +0800 Message-ID: <20170426030859.15420-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-20170425_200940_993736_09763C55 X-CRM114-Status: GOOD ( 14.40 ) 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" Hi Sirs, I sent this patch on 2017.4.5 but got no response, could you please check it? Maybe you have concern about the patch, your comments and suggestions are welcome! Best Regards 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; }