Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2515210ybl; Thu, 29 Aug 2019 09:11:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9eXn0kwfZWnyZW8ngeN+e2Zp9belTHy80tvf6ePyf2Vsa16kGrrT8A2tsI9M9zr8tmSxt X-Received: by 2002:aa7:938d:: with SMTP id t13mr12003092pfe.180.1567095076822; Thu, 29 Aug 2019 09:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567095076; cv=none; d=google.com; s=arc-20160816; b=KRmBbNDUZ1CpYrTXaM3np47AZAioeirB2oBYhqRGuzatOKqccy535p0jl80JVgUYUv 7FDTNhrFQySAwKp5ZuXOAlXjaLhNzn6v6Jhs7OPKVsa7F/tuKuDa7wc379rfTfFogpdF kib01giTd8d/F0VP1IHqPnDPMJRibXV4kYU6iqzkaUz2BKF0mBPX9izjWnvcX7k4hSYZ gM2xwKa46GwT/XnKWCyPwhrJ3f1cAzRBmHw/UfxKWhLrjG46FKw/7NmXYT1jOWLi240L 4Fx05YMq600bKlNJVZUzy9CvUXut1ZVDal2h8XmoDtmRYeVeP00//5sk8cOEP4yhG0hP Oi3g== 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 :in-reply-to:references:mime-version:dkim-signature; bh=rwrlLrsYCg5BNMxf+0gmxWY4/BokA4zfyVbGCkQeI20=; b=ZpI43fzPLGnE26ldPVrtQBUTCjJ10fDz1lMZkQZFm6mGc8elOFqY+AplWxstYM2Wdg MbXrGZNbO1WhyvVQSXrvBKOAVBfeSTEllBkOksD0OgdcFaGS4fLZBk7wYXBJ3bUZ+zKB xZOizThgYqq7xYetYt2yAdJp7ay2L/xqWEAn/rzOPIQvaTc2LeENAp5MjoShav6EO10+ HRhzz0r8pELA2g2KKyCQXFjMyMoVJwf2ep7Y9h79dBtnAY/9vkRiHLz/jIKsqKKF8W3Q gRhTji3CeiWeA2UTomMDFnqovqucQRL6VL6KJBYUQNd/y0+xbv+iL0U2a0t+yMIqd1gh pj1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=dHNY39JI; 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=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14si2348786pgy.255.2019.08.29.09.10.59; Thu, 29 Aug 2019 09:11:16 -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=@arista.com header.s=googlenew header.b=dHNY39JI; 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=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727255AbfH2QKC (ORCPT + 99 others); Thu, 29 Aug 2019 12:10:02 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:42677 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726739AbfH2QKC (ORCPT ); Thu, 29 Aug 2019 12:10:02 -0400 Received: by mail-io1-f67.google.com with SMTP id n197so6031982iod.9 for ; Thu, 29 Aug 2019 09:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rwrlLrsYCg5BNMxf+0gmxWY4/BokA4zfyVbGCkQeI20=; b=dHNY39JIAv4t/hard4v9AztwnWA3PiH3lqadNodm7DwVtoWszKezFxaD2nfGVJkrtV ruGnUOV1UOaaC5KZiqrXBTkN1HryCoM0N29dRyt45u3G6BDLTXcxCybflzpryFWWR6A+ KT2XZp3NdjE2AUA92YZgPVL1hCSU44LfYHW+GaK+Qwgmvfxoxl5GvKbJ/iyMiJ+T9C5Q WZCOWe8lV/XNs3mUbOqZpMEEbiLsTfm4yQrSjjxGX3rK8R1Be7eYy4JBChBFjJHUJSsC IcwNM4J6F3QHT6UwunNI3po7rDoDYGEK84vxmIxvQIi7/IvHqqLDq6BAItM7/61DWdGx yvow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rwrlLrsYCg5BNMxf+0gmxWY4/BokA4zfyVbGCkQeI20=; b=Ncg+tic5gfahHLsHcBKobeeBiyisMpqs2YW1MFGYVGrNYenaZffEIYD1gXnZsd6Aje 2xKMY+D9y8rYBRVEcj9YbU2sT8nKeRdKtl2cpm+a/tOnYCL4Wjc3nifuBozVY6I45aZ+ zzJQci93cnhsGY+ww60G9R21uUFQiOpxSXm9+p93g8YWhIbIYybhh4HuG/tTOB+yzSFO kDxefECQCE0I0EHO1J57DyI+HqVeX2TZ33cT9XOOBvRE/wxqz4kA0LG+GpGwcg2ZjRqq X3iF6DeMyuCUjKjAhEAu09OaG37PW3ykO1ARxXZarVyeVStZFbqq9AXLN0wFjS6DODS6 dafw== X-Gm-Message-State: APjAAAWvCFCEaGIiGaWoXrOsNmqPns5EkGBfSI2IH2bkFzyYv5u5gc/A Mwe23QZihiw6FB2JtGXgInIuPG+l45eXboubWLRZcQ== X-Received: by 2002:a5d:8591:: with SMTP id f17mr1593524ioj.5.1567095000975; Thu, 29 Aug 2019 09:10:00 -0700 (PDT) MIME-Version: 1.0 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> <20190829115608.GD28313@dhcp22.suse.cz> <1567093344.5576.23.camel@lca.pw> In-Reply-To: <1567093344.5576.23.camel@lca.pw> From: Edward Chron Date: Thu, 29 Aug 2019 09:09:48 -0700 Message-ID: Subject: Re: [PATCH 00/10] OOM Debug print selection and additional information To: Qian Cai Cc: Michal Hocko , Tetsuo Handa , Andrew Morton , Roman Gushchin , Johannes Weiner , David Rientjes , Shakeel Butt , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ivan Delalande 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 Thu, Aug 29, 2019 at 8:42 AM Qian Cai wrote: > > On Thu, 2019-08-29 at 08:03 -0700, Edward Chron wrote: > > On Thu, Aug 29, 2019 at 4:56 AM Michal Hocko wrote: > > > > > > 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. > > > > > > > +1: It makes sense to keep the report going to the dmesg to persist. > > That is where it has always gone and there is no reason to change. > > You can have several OOMs back to back and you'd like to retain the output. > > All the information should be kept together in the OOM report. > > > > > > > > > > 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. > > > > For very simple addition, to add a line of output this works. > > It would still be nice to address the fact the existing OOM Report prints > > all of the user processes or none. It would be nice to add some control > > for that. That's what we did. > > Feel like you are going in circles to "sell" without any new information. If you > need to deal with OOM that often, it might also worth working with FB on oomd. > > https://github.com/facebookincubator/oomd > > It is well-known that kernel OOM could be slow and painful to deal with, so I > don't buy-in the argument that kernel OOM recover is better/faster than a kdump > reboot. > > It is not unusual that when the system is triggering a kernel OOM, it is almost > trashed/dead. Although developers are working hard to improve the recovery after > OOM, there are still many error-paths that are not going to survive which would > leak memories, introduce undefined behaviors, corrupt memory etc. But as you have pointed out many people are happy with current OOM processing which is the report and recovery so for those people a kdump reboot is overkill. Making the OOM report at least optionally a bit more informative has value. Also making sure it doesn't produce excessive output is desirable. I do agree for developers having to have all the system state a kdump provides that and as long as you can reproduce the OOM event that works well. But that is not the common case as has already been discussed. Also, OOM events that are due to kernel bugs could leak memory and over time and cause a crash, true. But that is not what we typically see. In fact we've had customers come back and report issues on systems that have been in continuous operation for years. No point in crashing their system. Linux if properly maintained is thankfully quite stable. But OOMs do happen and root causing them to prevent future occurrences is desired.