Received: by 10.213.65.68 with SMTP id h4csp3829173imn; Tue, 10 Apr 2018 05:26:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx49eDAuwfZDMkc370S6yZKKFLuyqATJJD0WKMk4GvsL8hp9LeLwgi74U0xdtzGSGY0GdhThQ X-Received: by 2002:a17:902:64cf:: with SMTP id y15-v6mr214964pli.49.1523363214146; Tue, 10 Apr 2018 05:26:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523363214; cv=none; d=google.com; s=arc-20160816; b=O+sPtKxsBFemetxSkJG9F1C3KMKhkH1gayIrsyWPXo/gRL0TaP7M00bhSrm9nxqBPL RJXfEG2cxK0N/Ykw6YFtQnCeVL2mgHXkgMx6E3J+AbJh5UlKZRCbvEyDp/+6+MFKKNsB DWrAxb0YiI/H9jjZptw5MJUXg4CSCJrdhU01Osph0TFRb3FgHiMIBCLlozEOuo7z9bja YX1JCZTbbASKluwkxKTgsbrqPv6b7Axr4ff5R1POrTwbCkvi80WjUFXcxc72DShGEoGy Q+2LSdIH/Ol4sMAtWfnH6ym7XBwNEtlmyhv/d7QyuCda28JIAbjsZYPVSY0ZmqUkt8bY NqXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dmarc-filter:arc-authentication-results; bh=ffr0kwWDDLGt9OSvix92fqAmg6tjv+kicjm+6hiJxCM=; b=ga278xdL7EbatXzUvg2HaIDrLO//uZtxNgZSL2HPHnc3dYS1kS3ySR47/6eCvHFkCQ f7L88T/lSQ40zQzEiVsuS2VxetgMVz4/O7md3OcAs6rZoyxfo6ZTd7CYDb7qVqW53iOz V4Q+kyP39XhwZGqW/zfpDeLHu+cO0DhNxjNfwrVHFTr2Pa5MNrDf3wAhCxTxVvLXq3dd i8WrKS/emy6GI8PBWAwJyHjA1TJHeduIVGUzk8evW50YkMcwfRz1y3KHLG22zJB62PF3 zOLkH7F04YElA2FGp9oUzVtcqcPU4RHyNSqBv73OwkBMq3ZB5J3trBwhq2UAgjKlIalE 682A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3-v6si2542106plb.366.2018.04.10.05.26.17; Tue, 10 Apr 2018 05:26:54 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752761AbeDJMXU (ORCPT + 99 others); Tue, 10 Apr 2018 08:23:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:58174 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752428AbeDJMXT (ORCPT ); Tue, 10 Apr 2018 08:23:19 -0400 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E85F020652; Tue, 10 Apr 2018 12:23:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E85F020652 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Tue, 10 Apr 2018 08:23:16 -0400 From: Steven Rostedt To: Michal Hocko Cc: Zhaoyang Huang , Ingo Molnar , LKML Subject: Re: [PATCH v1] ringbuffer: Don't choose the process with adj equal OOM_SCORE_ADJ_MIN Message-ID: <20180410082316.263d34ec@gandalf.local.home> In-Reply-To: <20180410104902.GC21835@dhcp22.suse.cz> References: <20180409231230.1ab99e85@vmware.local.home> <20180410061447.GQ21835@dhcp22.suse.cz> <20180410074921.GU21835@dhcp22.suse.cz> <20180410081231.GV21835@dhcp22.suse.cz> <20180410090128.GY21835@dhcp22.suse.cz> <20180410104902.GC21835@dhcp22.suse.cz> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 10 Apr 2018 12:49:02 +0200 Michal Hocko wrote: > But you do realize that what you are proposing is by no means any safer, > don't you? The memory allocated for the ring buffer is _not_ accounted > to any process and as such it is not considered by the oom killer when > picking up an oom victim so you are quite likely to pick up an innocent > process to be killed. So basically you are risking an allocation runaway > completely hidden from the OOM killer. Now, the downside of the patch is > that the OOM_SCORE_ADJ_MIN task might get killed which is something that > shouldn't happen because it is a contract. I would call this an > unsolvable problem and a inherent broken design of the oom disabled > task. So far I haven't heard a single _argument_ why supporting such a > weird cornercase is desirable when your application can trivial do > > fork(); set_oom_score_adj(); exec("echo $VAR > $RINGBUFFER_FILE") We could do this as a compromise: diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index c9cb9767d49b..40c2e0a56c51 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -1185,6 +1185,12 @@ static int __rb_allocate_pages(long nr_pages, struct list_head *pages, int cpu) */ mflags = GFP_KERNEL | __GFP_RETRY_MAYFAIL; + /* If we can't OOM this task, then only allocate without reclaim */ + if (unlikely(current->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)) { + mflags = GFP_KERNEL | __GFP_NORETRY; + user_thread = false; /* do not set oom_origin */ + } + /* * If a user thread allocates too much, and si_mem_available() * reports there's enough memory, even though there is not. This way, if one sets OOM_SCORE_ADJ_MIN, then we wont set oom_origin for the task, but we also wont try hard to allocate memory if there is nothing immediately available. -- Steve