Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751710AbdIXGKt (ORCPT ); Sun, 24 Sep 2017 02:10:49 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:37066 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750880AbdIXGKr (ORCPT ); Sun, 24 Sep 2017 02:10:47 -0400 X-Google-Smtp-Source: AOwi7QDn19w+xD1eUcS5d9drmCKS+fU6u5ct+0RVk0tfh31gXFM2iEnJEFMcE0T00RUCx1f0kk3wRVHub88F5W2fb0w= MIME-Version: 1.0 In-Reply-To: <1506109927-17012-3-git-send-email-yang.s@alibaba-inc.com> References: <1506109927-17012-1-git-send-email-yang.s@alibaba-inc.com> <1506109927-17012-3-git-send-email-yang.s@alibaba-inc.com> From: Qixuan Wu Date: Sun, 24 Sep 2017 14:10:46 +0800 Message-ID: Subject: [PATCH 2/2] mm: oom: show unreclaimable slab info when kernel panic To: Yang Shi Cc: "cl@linux.com" , "penberg@kernel.org" , "rientjes@google.com" , "iamjoonsoo.kim@lge.com" , "akpm@linux-foundation.org" , "mhocko@kernel.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v8O6ArGs028872 Content-Length: 1776 Lines: 47 On Sat, Sep 23, 2017, Yang Shi wrote: > > Kernel may panic when oom happens without killable process sometimes it > is caused by huge unreclaimable slabs used by kernel. > > Although kdump could help debug such problem, however, kdump is not > available on all architectures and it might be malfunction sometime. > And, since kernel already panic it is worthy capturing such information > in dmesg to aid touble shooting. ...... > +void dump_unreclaimable_slab(void) > +{ > + struct kmem_cache *s, *s2; > + struct slabinfo sinfo; > + > + pr_info("Unreclaimable slab info:\n"); > + pr_info("Name Used Total\n"); > + > + /* > + * Here acquiring slab_mutex is unnecessary since we don't prefer to > + * get sleep in oom path right before kernel panic, and avoid race > + * condition. > + * Since it is already oom, so there should be not any big allocation > + * which could change the statistics significantly. > + */ > + list_for_each_entry_safe(s, s2, &slab_caches, list) { > + if (!is_root_cache(s) || (s->flags & SLAB_RECLAIM_ACCOUNT)) > + continue; > + > + memset(&sinfo, 0, sizeof(sinfo)); > + get_slabinfo(s, &sinfo); > + > + if (sinfo.num_objs > 0) > + pr_info("%-17s %10luKB %10luKB\n", cache_name(s), > + (sinfo.active_objs * s->size) / 1024, > + (sinfo.num_objs * s->size) / 1024); > + } > +} > + Seems it's a good feature and patch is fine, maybe modify like below is better. Change if (sinfo.num_objs > 0) to if (sinfo.num_objs > 0 && sinfo.actives_objs > 0)