From patchwork Sat Aug 4 13:29:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 10555769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6443613AC for ; Sat, 4 Aug 2018 13:30:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5305429C2E for ; Sat, 4 Aug 2018 13:30:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4717529C34; Sat, 4 Aug 2018 13:30:13 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A300A29C2E for ; Sat, 4 Aug 2018 13:30:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7678F6B0008; Sat, 4 Aug 2018 09:30:08 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 69FF46B000A; Sat, 4 Aug 2018 09:30:08 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51FFB6B000C; Sat, 4 Aug 2018 09:30:08 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id 004196B0008 for ; Sat, 4 Aug 2018 09:30:08 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id 90-v6so4883524pla.18 for ; Sat, 04 Aug 2018 06:30:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=IdtoHuo8UB7zKAK4hZYgZeI7adHAHLpPxjSBsB8Iy2s=; b=lP+5ATUV43I86TsBzRz/xUupcrJbL/r/VqJ4xfHHEi74I8aeA6jSPth0QwfIv+oSVN sCeNXjgKwNZA34neWkyFVOEElC/fu6lzZ2Y8PW1vOn9b/dzFBdWVJT/9WgorMrMBJPjy Pg35DAFLDXNzWs4AQAPxg+LgBQd+hcpVX9DGEJoCS67SMrQB5OsOssNk46ax59wwDIj0 XcHTNlpicw8fbPCtAiLTAGrgGBDHkA3xNV6ph1GVRnXYxU8E5NJZu07QMhmXagj7PhcK suTf+G6GOMZuIeM9vkerLGgRS0cNIIOEVdu+o68wHtKa8KYKjclUD2qGN5CyPZUxpJa7 Q+cw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp X-Gm-Message-State: AOUpUlGmONnbuGNvPy6VRqEde3vkau2ogg8RsIX/qfkoRl2Jb0y0ckiK EUUX8I8wEaVtKns0hCkNsWhVbnTyxPsdYaICsgiGfkFkHG6mup337qYQGPJ+fAWAmtXaldmARWY oG3fFZv7BjVkiZU1TnJ1s1Xk+fgZ3egJajRKj/ZZII0Fm5K1jkYGoNdS7nX+8aWpq5w== X-Received: by 2002:a63:5542:: with SMTP id f2-v6mr7811343pgm.37.1533389407643; Sat, 04 Aug 2018 06:30:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc6TiIkNMpPJ7zsUbZn+BLgv/AvKac1tGKiMGGaoWeBg76SSbOUV+WDV5UovVjUh8Irz8Kw X-Received: by 2002:a63:5542:: with SMTP id f2-v6mr7811265pgm.37.1533389406398; Sat, 04 Aug 2018 06:30:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533389406; cv=none; d=google.com; s=arc-20160816; b=WyiBy3ZEySwdtx9Jmo66pBRkf+HfqIMHAo9okZ3RENMd1BAj2PFMGgtzik5nD6QdI0 qtN7jWHGhPNX2c5UMYhO9jyyxX2QOIcF+La45pY3eMywC40owpf/QK4BgqohACVN2ylc 2R/SfX2zGgq6K+JhqsTAFQIcKQ6CdHIWCmIw9q2oy3dCYEcGXnqKULBR/6aJxwnTWSVe bbReqenVLm/9DJxtQNPR0l5C3DcCpoF0caYqUz88MjS+DqYIy0dFkvxUGHP8M5W2zNHZ E27X9wt+IzcNlmHBHiL14d+k5DgQjtZOvpw+CXW0m43T9dH6yOKJjqgcPz06mdoK0uCK q3JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=IdtoHuo8UB7zKAK4hZYgZeI7adHAHLpPxjSBsB8Iy2s=; b=jrKXHQm+Ioi0BUja1/pkd9dpEwc2dtQjolgkRx8aSrZ10CyA8maTE8vl+HiiknATWl qGeuCi0OVO1ZE4K6u9v0LZ1d6CaMBm3ErPrbCBTObYUwWUhy6jeNNfAK3aIYy1j/xdRx ggMHDD1ziJq1qMzuxmFdk02aqvFgfnGqcNeEYOAik92zSjQ4novJkRT25utPcN/h5hCO b2tSJesdRksj4Z6ttZjPRspi8XIWSobtTiOdwkQYuV4c6s8K889+gB0jWpxwDSbaeetj ywvNe/+oNt73c/fv+V3BfzQkEGOKYyViSDJjnvDcdo7WBBdfyxopS4Yqfr49w5goLqQy UiMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp Received: from www262.sakura.ne.jp (www262.sakura.ne.jp. [202.181.97.72]) by mx.google.com with ESMTPS id x4-v6si7158650pga.320.2018.08.04.06.30.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Aug 2018 06:30:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) client-ip=202.181.97.72; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp Received: from fsav105.sakura.ne.jp (fsav105.sakura.ne.jp [27.133.134.232]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w74DTnml005271; Sat, 4 Aug 2018 22:29:49 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav105.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav105.sakura.ne.jp); Sat, 04 Aug 2018 22:29:49 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav105.sakura.ne.jp) Received: from ccsecurity.localdomain (softbank126074194044.bbtec.net [126.74.194.44]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id w74DTiDK005246 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 4 Aug 2018 22:29:49 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) From: Tetsuo Handa To: linux-mm@kvack.org Cc: Tetsuo Handa , David Rientjes , Michal Hocko , Roman Gushchin Subject: [PATCH 3/4] mm, oom: Remove unused "abort" path. Date: Sat, 4 Aug 2018 22:29:45 +0900 Message-Id: <1533389386-3501-3-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1533389386-3501-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> References: <1533389386-3501-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Since oom_evaluate_task() no longer aborts, we can remove no longer used "abort" path in the callers. Signed-off-by: Tetsuo Handa Cc: Michal Hocko Cc: David Rientjes Cc: Roman Gushchin --- include/linux/memcontrol.h | 9 ++++----- mm/memcontrol.c | 18 +++++------------- mm/oom_kill.c | 34 ++++++++++++++++------------------ 3 files changed, 25 insertions(+), 36 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 652f602..396b01d 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -417,8 +417,8 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *, struct mem_cgroup *, struct mem_cgroup_reclaim_cookie *); void mem_cgroup_iter_break(struct mem_cgroup *, struct mem_cgroup *); -int mem_cgroup_scan_tasks(struct mem_cgroup *, - int (*)(struct task_struct *, void *), void *); +void mem_cgroup_scan_tasks(struct mem_cgroup *memcg, + void (*fn)(struct task_struct *, void *), void *arg); static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg) { @@ -917,10 +917,9 @@ static inline void mem_cgroup_iter_break(struct mem_cgroup *root, { } -static inline int mem_cgroup_scan_tasks(struct mem_cgroup *memcg, - int (*fn)(struct task_struct *, void *), void *arg) +static inline void mem_cgroup_scan_tasks(struct mem_cgroup *memcg, + void (*fn)(struct task_struct *, void *), void *arg) { - return 0; } static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 4e3c131..f743778 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1058,17 +1058,14 @@ static void invalidate_reclaim_iterators(struct mem_cgroup *dead_memcg) * @arg: argument passed to @fn * * This function iterates over tasks attached to @memcg or to any of its - * descendants and calls @fn for each task. If @fn returns a non-zero - * value, the function breaks the iteration loop and returns the value. - * Otherwise, it will iterate over all tasks and return 0. + * descendants and calls @fn for each task. * * This function must not be called for the root memory cgroup. */ -int mem_cgroup_scan_tasks(struct mem_cgroup *memcg, - int (*fn)(struct task_struct *, void *), void *arg) +void mem_cgroup_scan_tasks(struct mem_cgroup *memcg, + void (*fn)(struct task_struct *, void *), void *arg) { struct mem_cgroup *iter; - int ret = 0; BUG_ON(memcg == root_mem_cgroup); @@ -1077,15 +1074,10 @@ int mem_cgroup_scan_tasks(struct mem_cgroup *memcg, struct task_struct *task; css_task_iter_start(&iter->css, 0, &it); - while (!ret && (task = css_task_iter_next(&it))) - ret = fn(task, arg); + while ((task = css_task_iter_next(&it))) + fn(task, arg); css_task_iter_end(&it); - if (ret) { - mem_cgroup_iter_break(memcg, iter); - break; - } } - return ret; } /** diff --git a/mm/oom_kill.c b/mm/oom_kill.c index a743a8e..783f04d 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -312,13 +312,13 @@ static enum oom_constraint constrained_alloc(struct oom_control *oc) return CONSTRAINT_NONE; } -static int oom_evaluate_task(struct task_struct *task, void *arg) +static void oom_evaluate_task(struct task_struct *task, void *arg) { struct oom_control *oc = arg; unsigned long points; if (oom_unkillable_task(task, NULL, oc->nodemask)) - goto next; + return; /* * If task is allocating a lot of memory and has been marked to be @@ -331,24 +331,22 @@ static int oom_evaluate_task(struct task_struct *task, void *arg) points = oom_badness(task, NULL, oc->nodemask, oc->totalpages); if (!points || points < oc->chosen_points) - goto next; + return; /* Prefer thread group leaders for display purposes */ if (points == oc->chosen_points && thread_group_leader(oc->chosen)) - goto next; + return; select: if (oc->chosen) put_task_struct(oc->chosen); get_task_struct(task); oc->chosen = task; oc->chosen_points = points; -next: - return 0; } /* * Simple selection loop. We choose the process with the highest number of - * 'points'. In case scan was aborted, oc->chosen is set to -1. + * 'points'. */ static void select_bad_process(struct oom_control *oc) { @@ -359,8 +357,7 @@ static void select_bad_process(struct oom_control *oc) rcu_read_lock(); for_each_process(p) - if (oom_evaluate_task(p, oc)) - break; + oom_evaluate_task(p, oc); rcu_read_unlock(); } @@ -876,13 +873,12 @@ static void __oom_kill_process(struct task_struct *victim) * Kill provided task unless it's secured by setting * oom_score_adj to OOM_SCORE_ADJ_MIN. */ -static int oom_kill_memcg_member(struct task_struct *task, void *unused) +static void oom_kill_memcg_member(struct task_struct *task, void *unused) { if (task->signal->oom_score_adj != OOM_SCORE_ADJ_MIN) { get_task_struct(task); __oom_kill_process(task); } - return 0; } static void oom_kill_process(struct oom_control *oc, const char *message) @@ -1098,14 +1094,16 @@ bool out_of_memory(struct oom_control *oc) select_bad_process(oc); /* Found nothing?!?! Either we hang forever, or we panic. */ - if (!oc->chosen && !is_sysrq_oom(oc) && !is_memcg_oom(oc)) { - dump_header(oc, NULL); - panic("Out of memory and no killable processes...\n"); + if (!oc->chosen) { + if (!is_sysrq_oom(oc) && !is_memcg_oom(oc)) { + dump_header(oc, NULL); + panic("Out of memory and no killable processes...\n"); + } + return false; } - if (oc->chosen && oc->chosen != (void *)-1UL) - oom_kill_process(oc, !is_memcg_oom(oc) ? "Out of memory" : - "Memory cgroup out of memory"); - return !!oc->chosen; + oom_kill_process(oc, !is_memcg_oom(oc) ? "Out of memory" : + "Memory cgroup out of memory"); + return true; } /*