From patchwork Fri Sep 25 07:43:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Thelen X-Patchwork-Id: 7262831 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 619EABEEC1 for ; Fri, 25 Sep 2015 07:45:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7018520B5F for ; Fri, 25 Sep 2015 07:45:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 868AC20B5E for ; Fri, 25 Sep 2015 07:45:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755369AbbIYHpU (ORCPT ); Fri, 25 Sep 2015 03:45:20 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:34833 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753625AbbIYHpT (ORCPT ); Fri, 25 Sep 2015 03:45:19 -0400 Received: by pacfv12 with SMTP id fv12so100364936pac.2 for ; Fri, 25 Sep 2015 00:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=pN27fZifEltWelw7Re04DKU2k7qDOQfrWakoUPs+lqQ=; b=dL7Xq1HSQkpVqVXLJl3h/uTGg9Qd5XAZFyNCSXhglYvOd+x+gV4I3jq4QGjQYwAN9S Q/339gSkoM+OgHb8PARHRvf6HyiUJnCoV9y54wDN0ndcnUf43Y5LjbAnzvLxAcsogNlU dgZ5CwZPGzZ4725VW7/CKmIYENNNDTnT9aT8tAlMma9UUpOU4Fk9K8dgZqm3O2kVL1Wt xuL7SroER0dnzfUdW1fSj+DRahcOXbGNGLPtW6/nTTG6GVpN/K5CCzmKZPxXndoiJzpK 5GaUXZQPFW3VXqjxjcMDUxk6VdalvJV88LIcAy1y94y3ziSPqBAN00Zl6YY6MocYhnsp bhEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=pN27fZifEltWelw7Re04DKU2k7qDOQfrWakoUPs+lqQ=; b=b4hxojWkrkNjlISsSKg4yFWAPdgCkiL/7kn+PpG+IdM0/jCsMJ9ONbgLz9RdUxqx+v ptOOZ/9fLl4vpOJSTSmKlxK9OovGwE8gdHXVEWgk9CgWNuFK3B29ZTCwnyRvR6N+kn9L eBk9Uyd5PqLOhiiY2OG6RsnxgZpVcsi4XLmSIVnI15Ig9JZ7u2WFteN9Dkou05IxDV4K szsKJMNph5WyphLdnnjHswxxBAFjONalGV9I1uadoABZs+ko2tyNNrGrWcxe/HLVoBjY +CpnmJZU3+2iqmTtbedbIJauLKoT9K1TFLNr4mt9IlfMeeCEbH826otH3wqo0WDMVGse 4ZRw== X-Gm-Message-State: ALoCoQmn7ltUizEQ2/a1vUJwEQF9y79vFe3MBH5eOBoyRTEq0LQzFWHbAzOpbVXrXut+HlgG307S X-Received: by 10.68.218.104 with SMTP id pf8mr5303937pbc.31.1443167118440; Fri, 25 Sep 2015 00:45:18 -0700 (PDT) Received: from gthelen.mtv.corp.google.com ([172.17.128.37]) by smtp.gmail.com with ESMTPSA id tz1sm2327324pbc.50.2015.09.25.00.45.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 Sep 2015 00:45:16 -0700 (PDT) From: Greg Thelen To: Alexander Viro , Andrew Morton Cc: David Rientjes , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Thelen Subject: [PATCH] fs, seqfile: always allow oom killer Date: Fri, 25 Sep 2015 00:43:54 -0700 Message-Id: <1443167034-67530-1-git-send-email-gthelen@google.com> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since commit 5cec38ac866b ("fs, seq_file: fallback to vmalloc instead of oom kill processes") seq_buf_alloc() avoids calling the oom killer for PAGE_SIZE or smaller allocations; but larger allocations can use the oom killer via vmalloc(). Thus reads of small files can return ENOMEM, but larger files use the oom killer to avoid ENOMEM. Memory overcommit requires use of the oom killer to select a victim regardless of file size. Enable oom killer for small seq_buf_alloc() allocations. Signed-off-by: David Rientjes Signed-off-by: Greg Thelen Acked-by: Eric Dumazet --- fs/seq_file.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/seq_file.c b/fs/seq_file.c index 225586e141ca..a8e288755f24 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -25,12 +25,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; /* - * __GFP_NORETRY to avoid oom-killings with high-order allocations - - * it's better to fall back to vmalloc() than to kill things. + * 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. */ - buf = kmalloc(size, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN); + if (size > PAGE_SIZE) + gfp |= __GFP_NORETRY | __GFP_NOWARN; + buf = kmalloc(size, gfp); if (!buf && size > PAGE_SIZE) buf = vmalloc(size); return buf;