From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A57CFC433DB for ; Mon, 25 Jan 2021 06:22:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 707F822CAD for ; Mon, 25 Jan 2021 06:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725862AbhAYGWF (ORCPT ); Mon, 25 Jan 2021 01:22:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725960AbhAYGRf (ORCPT ); Mon, 25 Jan 2021 01:17:35 -0500 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B49FC061574 for ; Sun, 24 Jan 2021 22:16:21 -0800 (PST) Received: by mail-lj1-x22e.google.com with SMTP id f11so13864694ljm.8 for ; Sun, 24 Jan 2021 22:16:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/zaG6O0v8k3VXbwAFUClbwHTRxDGN6NUvBuA7zlt2y8=; b=Baoc6XDiAIsHiBtZhPHGxJRsI9B1ko2O4aEdadE4rddBzeeyIo+g44RIKb854Ztsu6 iusw3mCi9aw203TTlDC44xeCWljlllWqRC+tLT6t45DYIN6dR3Qxgy+uOO5Q3FF7dqlI 4hL5uek98BeTdJfSbfyODFmXXpHcehE3aZaeGG4hz3Q/HX7O7In8JVlNtOzBQPy2Ds6r YG6CzAd7DcbicbR09vhE1bfjN7dZrG4S2VU7q2ivNX4WAjpAgrD/gfPTvGx+AssZnceO mNpwgw7FyDDedJ8onTWIynXCsnOR2KFANoBPMtgg20YrRURDKKUCDaccVHCZcpOmIjfW FOzQ== 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=/zaG6O0v8k3VXbwAFUClbwHTRxDGN6NUvBuA7zlt2y8=; b=GP7hIh32UaX7ITOsll8SAGrZJ3K1YYdjMjSnPcfSkHDrA+7mTcZtPp7VS1kcg9k6EA 884ielv/xj64+Xq0UejWiTR7M57hyQngO5581fkP5/clma5v9HSxdbMpbauKRq4OZqhK vYNTKGjEjXEqoHOOiiaCWuB7xlC31VaMbDpGbSAF/YR7W25/DUQGOLoYJSam0zDiBmo0 hnoP+k07jJ2mwX5Wq3TIULbaVyvaULqG6V02Kfoes1X85iBS3oSRf4oKcovhzNo8FxHR MlqGlqrK6gTuy/fip306ZhwXmeePBiCARm/vn/4+5Gapn/yK89A7USLKSdxwEVQ2vBQY /Q/Q== X-Gm-Message-State: AOAM531ddiz4HUNlxayfFQzCWvENsu6OXZapjd0mHR7w9rvgcC5CuGjF EHqqF827/bOGl7Lz4AV/7Gm/IbXek3k+DV9wsBlHIg== X-Google-Smtp-Source: ABdhPJxU5eBGkVebQnOft5RGEvcNB2PFqwkcMvG25HAd6Fb6AYc+vtOp/pdjxyo5B44kXJXNss7vBBFgDun0A1I0s+k= X-Received: by 2002:a2e:91d0:: with SMTP id u16mr781133ljg.480.1611555379260; Sun, 24 Jan 2021 22:16:19 -0800 (PST) MIME-Version: 1.0 References: <1611313556-4004-1-git-send-email-sumit.garg@linaro.org> In-Reply-To: From: Sumit Garg Date: Mon, 25 Jan 2021 11:46:08 +0530 Message-ID: Subject: Re: [PATCH v3] kdb: Make memory allocations more robust To: Doug Anderson Cc: kgdb-bugreport@lists.sourceforge.net, Jason Wessel , Daniel Thompson , LKML , "# 4.0+" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks Doug for your comments. On Fri, 22 Jan 2021 at 22:55, Doug Anderson wrote: > > Hi, > > On Fri, Jan 22, 2021 at 3:06 AM Sumit Garg wrote: > > > > Currently kdb uses in_interrupt() to determine whether its library > > code has been called from the kgdb trap handler or from a saner calling > > context such as driver init. This approach is broken because > > in_interrupt() alone isn't able to determine kgdb trap handler entry from > > normal task context. This can happen during normal use of basic features > > such as breakpoints and can also be trivially reproduced using: > > echo g > /proc/sysrq-trigger > > I guess an alternative to your patch is to fully eliminate GFP_KDB. > It always strikes me as a sub-optimal design to choose between > GFP_ATOMIC and GFP_KERNEL like this. Presumably others must agree > because otherwise I'd expect that the overall kernel would have > something like "GFP_AUTOMATIC"? > > It doesn't feel like it'd be that hard to do something more explicit. > From a quick glance: > > * I think kdb_defcmd() and kdb_defcmd2() are always called in response > to a user typing something on the kdb command line. Those should > always be GFP_ATOMIC, right? > > * The one call that's not in kdb_defcmd() / kdb_defcmd2() is in > kdb_register_flags(). That can be called either during init time or > from kdb_defcmd2(). It doesn't seem like it'd be hard to rename > kdb_register_flags() to _kdb_register_flags() and add a "gfp_t flags" > to the end. Then the exported kdb_register_flags() would pass > GFP_KERNEL and the call from kdb_defcmd2() would pass GFP_ATOMIC: > Thanks for your suggestions. I agree with you that it's better to get rid of GFP_KDB. But I think we need to backport this fix to stable kernels as well, so IMO a minimal change like this would be better. I will rather push a seperate code refactoring patch to incorporate your suggestions. > > > We can improve this by adding check for in_dbg_master() instead which > > s/adding check/adding a check/ > Ack. If we don't have any further comments, can this be incorporated while applying this patch? > > > explicitly determines if we are running in debugger context. > > > > Cc: stable@vger.kernel.org > > Signed-off-by: Sumit Garg > > --- > > > > Changes in v3: > > - Refined commit description and Cc: stable@vger.kernel.org. > > > > Changes in v2: > > - Get rid of redundant in_atomic() check. > > > > kernel/debug/kdb/kdb_private.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > I would leave it up to Daniel to say whether he agrees that a full > removal of "GFP_KDB" would be a better solution. However, your patch > clearly improves the state of things, so: > > Reviewed-by: Douglas Anderson Thanks, Sumit