Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2821509pxb; Sun, 24 Jan 2021 22:24:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrXnvHmhT4dSRrMx/sDa/Llu9F1pWYL0dAj4R/Hqt4MptlI//m7nf7XVGoFgV1B7sr867H X-Received: by 2002:a17:906:9499:: with SMTP id t25mr544815ejx.339.1611555897830; Sun, 24 Jan 2021 22:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611555897; cv=none; d=google.com; s=arc-20160816; b=ypP5wzNuiuUxNxgkhZQ+OxHSEw9zmOKZRsCqZ3QGOebS/mQrDvpBvWqjPz0uMY1R1d n1UvrxOL0qJSiVEdCT7vIIT9HpwVb5No2g3n6UtBNzlKCqUB4KHyXqPeH3TFD8uGHUUr vnASHRo3DFw06ykKliLu0bQAIGwtVysIhrtW12Ee7OWoYSFQTdH6STJd8Tmqzr7Li18k Rs5kNGYiJljcOHyivULKfZwoBX7iyuw2O8aSRr/4MxuRMz7B5pTlRS6D+10RHXtxAJtW Myc4oKA8k8XXJ8FZRkNfAXJWKEe7L6Jrx0I4exKU6d+Rk5Wl/9mnKaBYHsePAcxBTRO0 qh4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/zaG6O0v8k3VXbwAFUClbwHTRxDGN6NUvBuA7zlt2y8=; b=Z7wUKtLCXCwBbMVBl7i91OLb0mg39nZ0HXGb3UhgCpiE5qjqKjjuB7NrXjoE6jwoyB dG9R+LZt2Jmg9STFprv+ByvwgeSm67HilyNTs12wDiLaG7kwCD27jpBmtgfnEuWPBHPM SE8XHUu2uQ0rk1s7lc0ZMzjkUL4b82BRBih0K/GgHomXgEBrMA5zbezS+WM7uEHkPzGz SPkqzmSsuACauCZ3Bkvuo4AGMZAuGiCovCpbHFElGq+8HfQCD1HsbMmuNb/z9EsTu5yc hnMgBBzmHi9HwAM+BHiIzWWBkAPGcRWpPZc+krUBEiBSG7yP5xaS26hOEv4mjtaTV3Z5 5bVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Baoc6XDi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si7208241edc.19.2021.01.24.22.24.34; Sun, 24 Jan 2021 22:24:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Baoc6XDi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727073AbhAYGVH (ORCPT + 99 others); Mon, 25 Jan 2021 01:21:07 -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-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