Received: by 10.213.65.68 with SMTP id h4csp3344434imn; Mon, 9 Apr 2018 19:36:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+b0yKAHSywq91QpGY2+QwK+HUDGG2DK2sOpyeII8y2xmHtXS04bL7t2RbGH+krk3N2M4+a X-Received: by 2002:a17:902:b411:: with SMTP id x17-v6mr6581447plr.402.1523327786418; Mon, 09 Apr 2018 19:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523327786; cv=none; d=google.com; s=arc-20160816; b=Idj7PPhvQuCL0qDZBoZf0/u97xwfZZfHsAyd1J6Qm/IKK0KquBcjzsZWCDmO8kCF+S jXIzCdc3ogurAvVEgxbOsgAcGLVMNXUB1LEdddp9b1RXFQ4EhnTrhxEPR8fh36rzM7ph scULq7iNcoCU9PUMPNk7XnH1+8ZVU+wncDrWSXRd5wy7kr2k/8qbzj3e2o0pIPkCsPfG pphrc2zLcSFxGHWZnLi1QoZNWzy0+DZZNy9wO6YThkEKe0g1MLEsVobr6ySIcxCOPFjK jvUa3wYjioZR9z2HcvPbYIU0PZuKraIQAkr/gfOF7XgonGJorBrdhFsylZHw2X3ddp4I fz4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=oeL2k3qLiztndEcRATmYlUMgheuhhVJT+qfKdFE02/A=; b=Vzbi+pURCs6ZjP20knX9R3bkccxDMiPjZQrE3/2MGGzzwJL8ODsa2L/IKZpZASzIXj 6QNbNoNQ8np8HL7NhGeniJLy4lkMrZrhZ3y+B0dymK7IIAo5WTcpZeWu63HpseR0akyd Mn1sPh7rTWLUMCdfBoAffY5pXpVPXPX5uFgQEoIy+G32C4cQTRJRVml9/Q9CvHtSsHyr GHWgoT9trl68j4F2+x8C/Pzl/ju++6jsuzBkuAMgJAUEuCG1IjKINgFmqumTQnfSsBJY pWDnOjNSHqiDSJbN3nsvGjqnVu4Tlva1MAEU8S1kt1ZOy74MlCZIZywTMRHTkwdUNRzx ji4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=M7OXhCug; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n34-v6si1573118pld.603.2018.04.09.19.35.49; Mon, 09 Apr 2018 19:36:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=M7OXhCug; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751968AbeDJCcj (ORCPT + 99 others); Mon, 9 Apr 2018 22:32:39 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:35879 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751919AbeDJCci (ORCPT ); Mon, 9 Apr 2018 22:32:38 -0400 Received: by mail-wm0-f45.google.com with SMTP id x82so20238704wmg.1 for ; Mon, 09 Apr 2018 19:32:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=oeL2k3qLiztndEcRATmYlUMgheuhhVJT+qfKdFE02/A=; b=M7OXhCugnICfv1mNnDRnVki0wj7wUjbFxu96n+L642jtp6l34kED+Zji72YVmRyeKp 5ouA8GuFEX5EUiyihkmxNJJiK7tFHqv/tTifomR3eaC+pDDWdCDNj4vtMgb5iEEFMn+K U/iBd8vOhPolFRy7ehbBxN/jLKsbZ5o4fIntTWIG00lYTR6hZ0vdjuQFkOAjRg9dxUDc 9ElB3//dbgRZE9yswirdmy7puu2NdCPBPsEJ4/W903hd64P8yt6VyDrNQ0vkPSB79BFe WtkY4c8V7qB1PHaH6NT3J7D5qmOeLgJ+oi7eUszS0QDRpdnoy3cnQqtpVkfhJzYZB1+Y rQ7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=oeL2k3qLiztndEcRATmYlUMgheuhhVJT+qfKdFE02/A=; b=B0Qn5HdohJ7x3GpLAhKHtQCA0W8ZyFeI/cAUkqY5Ob+gN54cSgEZh6d8H666mlViQ7 ZyPXi6k759/8iIs/znnx93YHGga0UgdHCl3moxosF5z5U3UNLthfhg49M1y4KJDc5Uiu HDGEQAj4/P0tmokR14xO49tEqOPRH2jIEpE1FtDJC5WQ0UM1C8egt50ATqKhJvpZc6TB XwEqn1IrFMHe5mbOc/YGmsMtE0zsnbZj5U7nQY3WjlKzH3ycyDbMZdHz2Knn+FI01oJg qCUIf9vMKPrI+LHDnP00rH4QnjozbsCD9BdjV/vubkxcp/JhQ4quvK2xkzpiGV8U4xQH x37g== X-Gm-Message-State: ALQs6tAiiC8c4Tt6+dYiNmRPJMpH08NcV6R4TNrsOAWROpy5ny7ImezK JjdmhJslkZWph1kidwGOEmmrazurGZeL/3JU9I01tQ== X-Received: by 10.80.201.203 with SMTP id c11mr542413edi.0.1523327556964; Mon, 09 Apr 2018 19:32:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.80.201.76 with HTTP; Mon, 9 Apr 2018 19:32:36 -0700 (PDT) In-Reply-To: References: <1523153783-20579-1-git-send-email-zhaoyang.huang@spreadtrum.com> <20180407234812.2bf2b24b@gandalf.local.home> <20180408084717.62ee4f9e@gandalf.local.home> <20180409094944.6399b211@gandalf.local.home> From: Zhaoyang Huang Date: Tue, 10 Apr 2018 10:32:36 +0800 Message-ID: Subject: Re: [PATCH v1] ringbuffer: Don't choose the process with adj equal OOM_SCORE_ADJ_MIN To: Steven Rostedt Cc: Ingo Molnar , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 10, 2018 at 8:32 AM, Zhaoyang Huang wrote: > On Mon, Apr 9, 2018 at 9:49 PM, Steven Rostedt wrote: >> On Mon, 9 Apr 2018 08:56:01 +0800 >> Zhaoyang Huang wrote: >> >>> >> >>> >> if (oom_task_origin(task)) { >>> >> points = ULONG_MAX; >>> >> goto select; >>> >> } >>> >> >>> >> points = oom_badness(task, NULL, oc->nodemask, oc->totalpages); >>> >> if (!points || points < oc->chosen_points) >>> >> goto next; >>> > >>> > And what's wrong with that? >>> > >>> > -- Steve >>> I think the original thought of OOM is the flag 'OOM_SCORE_ADJ_MIN' is >>> most likely to be set by process himself via accessing the proc file, >>> if it does so, OOM can select it as the victim. except, it is >>> reluctant to choose the critical process to be killed, so I suggest >>> not to set such heavy flag as OOM_SCORE_ADJ_MIN on behalf of -1000 >>> process. >> >> Really, I don't think tasks that are setting OOM_CORE_ADJ_MIN should be >> allocating a lot of memory in the kernel (via ring buffer). It sounds >> like a good way to wreck havoc on the system. >> >> It's basically saying, "I'm going to take up all memory, but don't kill >> me, just kill some random user on the system". >> >> -- Steve > Sure, but the memory status is dynamic, the process could also exceed the limit > at the moment even it check the available memory before. We have to > add protection > for such kind of risk. It could also happen that the critical process > be preempted by > another huge memory allocating process, which may cause insufficient memory when > it schedule back. For bellowing scenario, process A have no intension to exhaust the memory, but will be likely to be selected by OOM for we set OOM_CORE_ADJ_MIN for it. process A(-1000) process B i = si_mem_available(); if (i < nr_pages) return -ENOMEM; schedule ---------------> allocate huge memory <------------- if (user_thread) set_current_oom_origin(); for (i = 0; i < nr_pages; i++) { bpage = kzalloc_node