From patchwork Sat May 14 07:52:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zackary Liu X-Patchwork-Id: 12849726 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E094C433F5 for ; Sat, 14 May 2022 07:52:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A4186B0073; Sat, 14 May 2022 03:52:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 753558D0001; Sat, 14 May 2022 03:52:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 643BF6B0078; Sat, 14 May 2022 03:52:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 56B0F6B0073 for ; Sat, 14 May 2022 03:52:37 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 234D920B8D for ; Sat, 14 May 2022 07:52:37 +0000 (UTC) X-FDA: 79463581554.03.60AA336 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf19.hostedemail.com (Postfix) with ESMTP id 982F01A00B9 for ; Sat, 14 May 2022 07:52:27 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id l7-20020a17090aaa8700b001dd1a5b9965so9768400pjq.2 for ; Sat, 14 May 2022 00:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=9kAA0uCEYwZFDz59hPllk4M4/jt+7xzfL8ut7F5jG6Q=; b=i8f3tAxBvaDfFYiDPd/kfXBTvmRLxSQjGJwGgd5Lla/1qNwGm2bvlqEn8+j5k4OyEY Ys0QQQ+aUww+WnvB3a4WEcH/rBiotPA6kXy4PZnHQbuvi8QNQ6EophHw03VlSHuqfYYT RL9314D8x5C5lBSGjf+JJ1XrJ+WzLviQuzh7jvANHHGJH9Tu6Ep4/mJ6JD54Oiv4jMun Fwv+HC5Vo/D9pV+8xZg6/FAsQCaqVLKpTIPcdX1lKLPBeFz44pd1FlRq9dmThQBcFVvc /Gr3DVI/RrZ8xWlEKVI86S7SFzIrjkJ9R9nQLFYlQ5lYBsRLIMVw/p0t0NKNuETI6Dxp 85xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=9kAA0uCEYwZFDz59hPllk4M4/jt+7xzfL8ut7F5jG6Q=; b=HJvN9JasZ7mmYz4f9AXXkVaYvcNjxnlWgr/ZfbIAHFE6tYsmewbWv9R4L4C1baFHlI NhDQqiHlmJZAK8S9uZuUj+1GzBF1Z61FWm/8gYwcOPDssgVbAfQ1bBsX5l8gOoWf43QA rkN/Sc3lGE0/jsCkpWDwVcdIBhHGjM7t4NX2TJVNJwmc1w26CBIXOrda/X4XQVHPo61q iwMdCXRp4bH3jepQGsCnJJ1FFHCmmKE8hYlF8cG3TZHFCnv0PeJSJdsskefrFu3uZE+l 88WYoS9zY4xqg3+VuwyfBMzCVfqyXReZqkV3p0B/BilmGo1ByRFFglx0JWp433iqJSm7 CNAQ== X-Gm-Message-State: AOAM533szHXQLBL7Wzb1wTuxkUyYrjEQvTAkDMWE3EdrHvqLE13D+Eqo B8WNux2UGcLSB7Kstce9roQc/Gx6Ev0= X-Google-Smtp-Source: ABdhPJwALc97+Ztc4kOjUbmkvfnjzktBbydfixTh093DwDApZfPo7PIKJ5gqQv7GyZie3g2/VhqGLA== X-Received: by 2002:a17:90b:350d:b0:1dc:6680:6f1d with SMTP id ls13-20020a17090b350d00b001dc66806f1dmr19966890pjb.27.1652514755798; Sat, 14 May 2022 00:52:35 -0700 (PDT) Received: from pc ([199.15.76.19]) by smtp.gmail.com with ESMTPSA id ij16-20020a170902ab5000b0015e8d4eb209sm3104746plb.83.2022.05.14.00.52.33 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 14 May 2022 00:52:34 -0700 (PDT) Date: Sat, 14 May 2022 15:52:28 +0800 From: Zhaoyu Liu To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm/oom_kill: break evaluation when a task has been selected Message-ID: <20220514075223.GA11384@pc> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=i8f3tAxB; spf=pass (imf19.hostedemail.com: domain of zackary.liu.pro@gmail.com designates 209.85.216.65 as permitted sender) smtp.mailfrom=zackary.liu.pro@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 982F01A00B9 X-Stat-Signature: mkstau8rptmu39o4hur1y4cn6cqg7za8 X-HE-Tag: 1652514747-273249 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: oom points no longer need to be calculated if a task is oom_task_origin(), so return 1 to stop the oom_evaluate_task(). Signed-off-by: Zhaoyu Liu --- mm/oom_kill.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 3996301450e8..b407fba21d19 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -308,7 +308,7 @@ static enum oom_constraint constrained_alloc(struct oom_control *oc) static int oom_evaluate_task(struct task_struct *task, void *arg) { struct oom_control *oc = arg; - long points; + long points = 0; if (oom_unkillable_task(task)) goto next; @@ -349,7 +349,7 @@ static int oom_evaluate_task(struct task_struct *task, void *arg) oc->chosen = task; oc->chosen_points = points; next: - return 0; + return points == LONG_MAX; abort: if (oc->chosen) put_task_struct(oc->chosen);