Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2186423ybl; Thu, 29 Aug 2019 04:57:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqza5nGFpX4YohCskwl9UQRhk3d51aRl6ifLg9U1xtl7zsJ/mg6ne8w2V9/Ylm9d7zD7vrKo X-Received: by 2002:a17:902:fe0f:: with SMTP id g15mr9166345plj.2.1567079854295; Thu, 29 Aug 2019 04:57:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567079854; cv=none; d=google.com; s=arc-20160816; b=lY9O+Qx4GT3FSEEfP3INCDPVzpoybYgtOQFd9jMTXkg63CDA5dm4KIqnaqlbIWoeCC jAirHbnwfqorKn9DrkCxT9vWJEKAZKUoOxZE7viHw3H7ipM8DyJPdbbAOit3kIE+/Gaw LSj0GioFH6iJWm8UjfC0FOmLQAjkpvF8pDUFshr3Lml4+UQkjXJOh5GE3i38aw8Z5QHN UJmgR4PoGjhOj9/Kslltw01WORJpGKDWyOsMeFtF32Fe1lLDJI3Q07u0A3SADsEn3VHx 9YZmbu1yPK3F4aYh77HP97cXp+zu0FO5xywWY+qEtp/utrGk1Oyxy6EBZxZCnLWhsARO TtmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=j9mY3mijMWKjoDuxRxKAOp7ZrP8poJErJCbODxDDo1g=; b=ooIUw9TgzoG0pCZU7Q37bHFkLNm85RWh0+s+J9gYZBil+xwPF4IBbZjmUMuGMuw7jl tlI/rOFp0E6Aj2GBmXR9C8sC2xbvTqepIHdKKWTS5WoeohQlzcKepAR42/eSnUCZozaP YbNk40ysr/Oxb+RkchiCCYkyYyys+MEqRqHjqoDGaDiayAs7r2TnAwAZ7ebVm3S9PBhZ +8roYenNiz8jKpDNEuLOOPKAdIfV21fF41Qdh8jMd0138/BZq6eVdIE7OJKkYKkEOMju 6fIWO1mMWHqcYmxICUjOZJmeDsVH5ANLeUHVbvQ4KJl9kwiYwojqN4YBQif1b5ywj/Km Z6EQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k33si1846759pgi.563.2019.08.29.04.57.17; Thu, 29 Aug 2019 04:57:34 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbfH2L4L (ORCPT + 99 others); Thu, 29 Aug 2019 07:56:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:48806 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726379AbfH2L4L (ORCPT ); Thu, 29 Aug 2019 07:56:11 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2026AB680; Thu, 29 Aug 2019 11:56:09 +0000 (UTC) Date: Thu, 29 Aug 2019 13:56:08 +0200 From: Michal Hocko To: Tetsuo Handa Cc: Edward Chron , Andrew Morton , Roman Gushchin , Johannes Weiner , David Rientjes , Shakeel Butt , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ivan Delalande Subject: Re: [PATCH 00/10] OOM Debug print selection and additional information Message-ID: <20190829115608.GD28313@dhcp22.suse.cz> References: <20190826193638.6638-1-echron@arista.com> <20190827071523.GR7538@dhcp22.suse.cz> <20190828065955.GB7386@dhcp22.suse.cz> <20190829071105.GQ28313@dhcp22.suse.cz> <297cf049-d92e-f13a-1386-403553d86401@i-love.sakura.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <297cf049-d92e-f13a-1386-403553d86401@i-love.sakura.ne.jp> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 29-08-19 19:14:46, Tetsuo Handa wrote: > On 2019/08/29 16:11, Michal Hocko wrote: > > On Wed 28-08-19 12:46:20, Edward Chron wrote: > >> Our belief is if you really think eBPF is the preferred mechanism > >> then move OOM reporting to an eBPF. > > > > I've said that all this additional information has to be dynamically > > extensible rather than a part of the core kernel. Whether eBPF is the > > suitable tool, I do not know. I haven't explored that. There are other > > ways to inject code to the kernel. systemtap/kprobes, kernel modules and > > probably others. > > As for SystemTap, guru mode (an expert mode which disables protection provided > by SystemTap; allowing kernel to crash when something went wrong) could be used > for holding spinlock. However, as far as I know, holding mutex (or doing any > operation that might sleep) from such dynamic hooks is not allowed. Also we will > need to export various symbols in order to allow access from such dynamic hooks. This is the oom path and it should better not use any sleeping locks in the first place. > I'm not familiar with eBPF, but I guess that eBPF is similar. > > But please be aware that, I REPEAT AGAIN, I don't think neither eBPF nor > SystemTap will be suitable for dumping OOM information. OOM situation means > that even single page fault event cannot complete, and temporary memory > allocation for reading from kernel or writing to files cannot complete. And I repeat that no such reporting is going to write to files. This is an OOM path afterall. > Therefore, we will need to hold all information in kernel memory (without > allocating any memory when OOM event happened). Dynamic hooks could hold > a few lines of output, but not all lines we want. The only possible buffer > which is preallocated and large enough would be printk()'s buffer. Thus, > I believe that we will have to use printk() in order to dump OOM information. > At that point, Yes, this is what I've had in mind. > > static bool (*oom_handler)(struct oom_control *oc) = default_oom_killer; > > bool out_of_memory(struct oom_control *oc) > { > return oom_handler(oc); > } > > and let in-tree kernel modules override current OOM killer would be > the only practical choice (if we refuse adding many knobs). Or simply provide a hook with the oom_control to be called to report without replacing the whole oom killer behavior. That is not necessary. -- Michal Hocko SUSE Labs