From patchwork Tue May 11 18:50:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251831 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=-10.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT 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 D98FBC433ED for ; Tue, 11 May 2021 18:51:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6A2BB61433 for ; Tue, 11 May 2021 18:51:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A2BB61433 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3EFE56B0070; Tue, 11 May 2021 14:51:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 39C936B0072; Tue, 11 May 2021 14:51:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23EE36B0073; Tue, 11 May 2021 14:51:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id 0CF126B0070 for ; Tue, 11 May 2021 14:51:22 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B3DA08E71 for ; Tue, 11 May 2021 18:51:21 +0000 (UTC) X-FDA: 78129843162.25.C9310C1 Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) by imf04.hostedemail.com (Postfix) with ESMTP id 09AC33C7 for ; Tue, 11 May 2021 18:51:14 +0000 (UTC) Received: by mail-io1-f43.google.com with SMTP id k16so5078587ios.10 for ; Tue, 11 May 2021 11:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7sTUPuFc66ybePyVc1BipkRA9wzdceMEI5lxpFNGBTY=; b=Ejt6pYdhRRT/Y99OtH6AqvCn+KURqUFlvSmqQYYC6RQ6BuuQljq3uRuLepMpaUyF2O q5H+LqUdg0JzK9dJcSVcRe5CZIuLe1ExMHs9WDYbHFnwjPeu60302dqMM9Vga1EM+lNQ uiLjx9PijnJNal5gs9NqFR2fU/Afuk+UFubRaGO9H5dg/h7BIkAja45+pIIsETAxhG28 6cvcu+yFJO4Yyv8Lgdc7vhXV+379QExU+vqoSYrsN0eN43JNav3jcBGoUIwwKTQbvlyf vBMaUxQbIm0LErKcUxIxqNTz2LkWP493xXiAwywvTYA5rSXSdi3O70ohUDLCx92+iVi/ Sctg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7sTUPuFc66ybePyVc1BipkRA9wzdceMEI5lxpFNGBTY=; b=cP+AIX5lJfhAoGG2ptfcjU0uydEwfXo4yn7dC2xODhK7WQMNX42uqCfo6fwNW9EIgk GXad8Goh0IOrbVoXW1hcScIghjFkpq41pgGq+vGfuJvjWhERr/vPMaS89ZYITOxfJ9jw UR/oLIVqJUveukavjpamQZ4ibpkeR2EWbc0YEgGyK9+OE6tmzpxQEKcXq/D/E3y70foN ZTKpF8pVBN46k1qCz9Poj754th1wToDT6TxMaIH5iGfPQjV4IMCHmVeZyj5hFkiQVwG6 LTIK4Ixmoak4NpPO4L9ZT4Sf7flFyXsV8GiXFnmEhKwxq9YIIIL7XGoQUd/17NGraGgm awQQ== X-Gm-Message-State: AOAM53010vU1lTH5sFOSIFZzdhgS3sFhTXhWlEpUA9Yhozx9vGugkK4G QZzMgrzxgH2g/g763kMc1W0= X-Google-Smtp-Source: ABdhPJzfp/aDRmoziPojTcrdukG+4wgAm6I/Yg15+Asnz8wLXjxY1VrZGxPuvnMMl1uFWN2iXZsHYg== X-Received: by 2002:a02:bb98:: with SMTP id g24mr28108373jan.19.1620759080669; Tue, 11 May 2021 11:51:20 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:20 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 01/28] dyndbg: avoid calling dyndbg_emit_prefix when it has no work Date: Tue, 11 May 2021 12:50:30 -0600 Message-Id: <20210511185057.3815777-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 09AC33C7 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=Ejt6pYdh; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.43 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Rspamd-Server: rspam03 X-Stat-Signature: 5drfu4s6s3mtma94jefwi86iyu49peat Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf04; identity=mailfrom; envelope-from=""; helo=mail-io1-f43.google.com; client-ip=209.85.166.43 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759074-173111 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Wrap function in a static-inline one, which checks flags to avoid calling the function unnecessarily. And hoist its output-buffer initialization to the grand-caller, which is already allocating the buffer on the stack, and can trivially initialize it too. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 5 +++++ lib/dynamic_debug.c | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index a57ee75342cf..dce631e678dd 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -32,6 +32,11 @@ struct _ddebug { #define _DPRINTK_FLAGS_INCL_FUNCNAME (1<<2) #define _DPRINTK_FLAGS_INCL_LINENO (1<<3) #define _DPRINTK_FLAGS_INCL_TID (1<<4) + +#define _DPRINTK_FLAGS_INCL_ANY \ + (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME |\ + _DPRINTK_FLAGS_INCL_LINENO | _DPRINTK_FLAGS_INCL_TID) + #if defined DEBUG #define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT #else diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c70d6347afa2..ede4a491ee87 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -586,13 +586,11 @@ static int remaining(int wrote) return 0; } -static char *dynamic_emit_prefix(const struct _ddebug *desc, char *buf) +static char *__dynamic_emit_prefix(const struct _ddebug *desc, char *buf) { int pos_after_tid; int pos = 0; - *buf = '\0'; - if (desc->flags & _DPRINTK_FLAGS_INCL_TID) { if (in_interrupt()) pos += snprintf(buf + pos, remaining(pos), " "); @@ -618,11 +616,18 @@ static char *dynamic_emit_prefix(const struct _ddebug *desc, char *buf) return buf; } +static inline char *dynamic_emit_prefix(struct _ddebug *desc, char *buf) +{ + if (unlikely(desc->flags & _DPRINTK_FLAGS_INCL_ANY)) + return __dynamic_emit_prefix(desc, buf); + return buf; +} + void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) { va_list args; struct va_format vaf; - char buf[PREFIX_SIZE]; + char buf[PREFIX_SIZE] = ""; BUG_ON(!descriptor); BUG_ON(!fmt); @@ -655,7 +660,7 @@ void __dynamic_dev_dbg(struct _ddebug *descriptor, if (!dev) { printk(KERN_DEBUG "(NULL device *): %pV", &vaf); } else { - char buf[PREFIX_SIZE]; + char buf[PREFIX_SIZE] = ""; dev_printk_emit(LOGLEVEL_DEBUG, dev, "%s%s %s: %pV", dynamic_emit_prefix(descriptor, buf), @@ -684,7 +689,7 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, vaf.va = &args; if (dev && dev->dev.parent) { - char buf[PREFIX_SIZE]; + char buf[PREFIX_SIZE] = ""; dev_printk_emit(LOGLEVEL_DEBUG, dev->dev.parent, "%s%s %s %s%s: %pV", @@ -720,7 +725,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, vaf.va = &args; if (ibdev && ibdev->dev.parent) { - char buf[PREFIX_SIZE]; + char buf[PREFIX_SIZE] = ""; dev_printk_emit(LOGLEVEL_DEBUG, ibdev->dev.parent, "%s%s %s %s: %pV", From patchwork Tue May 11 18:50:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251833 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 A0829C433B4 for ; Tue, 11 May 2021 18:51:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 49C9F6190A for ; Tue, 11 May 2021 18:51:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49C9F6190A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3C7AE6B0072; Tue, 11 May 2021 14:51:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DA606B0073; Tue, 11 May 2021 14:51:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0DFDD6B0074; Tue, 11 May 2021 14:51:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0144.hostedemail.com [216.40.44.144]) by kanga.kvack.org (Postfix) with ESMTP id E7FF86B0072 for ; Tue, 11 May 2021 14:51:22 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A69078249980 for ; Tue, 11 May 2021 18:51:22 +0000 (UTC) X-FDA: 78129843204.06.6D59450 Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) by imf12.hostedemail.com (Postfix) with ESMTP id 47A5CED for ; Tue, 11 May 2021 18:51:06 +0000 (UTC) Received: by mail-io1-f52.google.com with SMTP id p11so19130218iob.9 for ; Tue, 11 May 2021 11:51:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dS6uHjz9CiOVRNfXnDoINC1MJqAgC4MzLCRQqOhkkl0=; b=TijEh3JEcPfbLKoUPT9uVq7Hr4n03fdW7UhfG0dTCxQaorpz+yRmuehSi3KjdJI3Y3 cRVnsPnwGh1rHGnwTnXa/9kS7twWqnzJE+KWu95nphFw7dyc3W/1AN8wWWQ9SN+9lRLA KT7gefE3LFhehVbQJk+rrRgqHR3C9wD3+PeowYIByWL7sKrKBcgjaE8p7VObAyI1Py/M zHK+E43NdI6mLDJ4MiiR+q8XSWsYWXuxbrpE1OgDfmMRWiT8ujWKgGsRXr9zotn51O3O 4I2gaSzI2p5I5nJOWzwXMojqGr31FUz20OxyfW7mIw+HuH8/ZFZ//EtKOa/OIxfvOm56 A9ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dS6uHjz9CiOVRNfXnDoINC1MJqAgC4MzLCRQqOhkkl0=; b=oZy4ZQN59J3HVBZyjwI0mVjQFW7h0Q/EOhXpl+/itrcceXvPo7lkHDmb/q87wKw9BJ 6HR1UBb/CpAcXE8xFRFpDRxjEsus6M3x0xjZUJlO6jEm5r5wJxgtGon/kRK1uZr0FnLT 5kGSjedup9S5vDsqe/+ljKtXM6MCb1wEs26kLZ+cV6azBjkauxaXjrGriZ6asx4HQ53f gBiN9HOETNLLHdJS2rFY2L1Y+2msBWEou01GUbsZosGbAXMdHtBHGVJiIB3zdAQuW5Gp diKS2q2JWCXkyC1p/YFRgRDwb/TiKiRLhPOkWjLs1Gluwr3ZT9wxueHukM4OgK14osUE 57AA== X-Gm-Message-State: AOAM533zAsWlfi5yM7pu/FYV/o3oYFZZfUvMJbAU94DviKSAeUS7UIFi N9xqy2XY8hBhMujkQ9qTvbbJK4EX2iZ21g== X-Google-Smtp-Source: ABdhPJxOm1qEuoS1k2upmIrWUWJGvoRYh2qw756gXTMjIJOxYp9oMZsSRyeI/qgyTjx+liffFgke3A== X-Received: by 2002:a05:6638:2157:: with SMTP id z23mr27889930jaj.35.1620759081774; Tue, 11 May 2021 11:51:21 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:21 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 02/28] dyndbg: drop uninformative vpr_info Date: Tue, 11 May 2021 12:50:31 -0600 Message-Id: <20210511185057.3815777-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 47A5CED Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=TijEh3JE; spf=pass (imf12.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.52 as permitted sender) smtp.mailfrom=jimcromie@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Stat-Signature: af5pqjf6rw8nkxqcdaxqxafapp6qr6wk Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf12; identity=mailfrom; envelope-from=""; helo=mail-io1-f52.google.com; client-ip=209.85.166.52 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759066-126069 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Remove a vpr_info which I added in 2012, when I knew even less than now. In 2020, a simpler pr_fmt stripped it of context, and any remaining value. no functional change. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index ede4a491ee87..3a7d1f9bcf4d 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -920,7 +920,6 @@ static const struct seq_operations ddebug_proc_seqops = { static int ddebug_proc_open(struct inode *inode, struct file *file) { - vpr_info("called\n"); return seq_open_private(file, &ddebug_proc_seqops, sizeof(struct ddebug_iter)); } From patchwork Tue May 11 18:50:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251835 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 74B50C43460 for ; Tue, 11 May 2021 18:51:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EA2596191C for ; Tue, 11 May 2021 18:51:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA2596191C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 639226B0074; Tue, 11 May 2021 14:51:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 59C776B0075; Tue, 11 May 2021 14:51:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C68C6B0078; Tue, 11 May 2021 14:51:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0251.hostedemail.com [216.40.44.251]) by kanga.kvack.org (Postfix) with ESMTP id 249146B0074 for ; Tue, 11 May 2021 14:51:24 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D86B11801C196 for ; Tue, 11 May 2021 18:51:23 +0000 (UTC) X-FDA: 78129843246.25.80B6AD1 Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) by imf20.hostedemail.com (Postfix) with ESMTP id 58BF53C7 for ; Tue, 11 May 2021 18:51:23 +0000 (UTC) Received: by mail-io1-f44.google.com with SMTP id i7so11698452ioa.12 for ; Tue, 11 May 2021 11:51:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ANa3RrA8GQr0AoP/19LhHIjfuWvBcIu4Kb3z3nXIqtc=; b=qYbO3nNzd+G95xmvT1sXJWHSXDZnN3Kc2IM9OMUMm0RcS59Zdwb1Rk+OqTPk3ZcWnv vRT/Ku+pPGbKCmdJvDImSzDKuGelMWBOCUQp9+dHqhzdBSc5On1RIVppqozqNq5MlMy/ Rz6zEn5Oh7VYALMrNjpDJIj6b8pypLGkIW2etZwvyaDTcQbRFSpV9fZvoBd+BCdl+tjc Dxo13ZWqxif3Tqic8R0CgrfQBzazQZPP6ikR+fXZdtkVBRB6qL1JXA1xETB2u7QMYnPb 5ODSYug0mYWoCtu2k7/LnUoyO8QKGhRwbywtw4mIPprUwAgxMC0TdJXAMhyf5AtBYMc2 iURw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ANa3RrA8GQr0AoP/19LhHIjfuWvBcIu4Kb3z3nXIqtc=; b=lzDrGtgA9pC25bSdoBA00u0u7gvAXyCz/SjvzjQNNMJPFGf+b+OwKiFeMilWUTQbKN kwhzE8WN9k2xGniVw+ehGT6lAjeF6ZETgoYvUVDEVm4VM2SdIBkANja7Qe2rJi5eo/Os VK2UjffMSPUM2AixaJTI08ouswzu1hmoledxWf78gEqZPforgdjIX1nHwmcnkz64nVbE Vr1YvpS49sUTKnTKpCN2dvnGDH18zYXzXrnJfTXy2D/urQlt8lXnLitvowgIoUl7a+8v OKuUcTagjcVcyV+gHI1vKIsaCdGBATAmZoiIxi3oeV+usais5O6cq3Sr+cvi1CDjCTOX mWjw== X-Gm-Message-State: AOAM533Sbkb1sHh9wajnPDqTn5iy15dnO8tBCTwLpWQ7KN/pmNLxjfvI JGAhYJBR4fJtvCatUsP5j3o= X-Google-Smtp-Source: ABdhPJwQ0jsvbKpZ/nPHup3oWgJuFJjfpY0pyZZeKcAbTFoPpJCEo+httTZOyguCTVAyymZwIrKJNw== X-Received: by 2002:a02:cac6:: with SMTP id f6mr28031950jap.118.1620759082905; Tue, 11 May 2021 11:51:22 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:22 -0700 (PDT) From: Jim Cromie To: Arnd Bergmann , Jason Baron , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 03/28] dyndbg: split struct _ddebug's display fields to new _ddebug_site Date: Tue, 11 May 2021 12:50:32 -0600 Message-Id: <20210511185057.3815777-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=qYbO3nNz; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.44 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 58BF53C7 X-Stat-Signature: w5b54hywogh9ztxcmjreun1xjjtfszwd Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf20; identity=mailfrom; envelope-from=""; helo=mail-io1-f44.google.com; client-ip=209.85.166.44 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759083-590690 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Struct _ddebug has 2 kinds of fields: essential & optional/compressible. Move the 3 optional fields: module, function, file into a new struct _ddebug_site, and add pointer to it from _ddebug. These fields are optional in that they are primarily used to generate the optional "module:func:line" log prefix. They're also used to display control, and to select callsites to >control. lineno is arguably optional too, but it uses spare bytes in struct _ddebug, so leaving it is free. The "__dyndbg" ELF section contains the array of struct _ddebugs for all the pr-debugs in the kernel/module. Reuse this pattern for the new "__dyndbg_sites" section. The new ptr increases memory footprint, but it is temporary scaffolding; once we can map from _ddebugs[N] --> _ddebug_sites[N] indirectly, we can drop site pointer, regaining worst case memory parity with master. The indirection gives several advantages: - site ptr lets us decouple the 2 arrays we can properly isolate dependencies by allowing null site - the moved display fields are inherently hierarchical, and the linker section is ordered; so (module, file, function) have repeating values (90%, 85%, 45%). This is readily compressible, even with a simple field-wise run length encoding. Since I'm splitting the struct, I also reordered the fields to match the hierarchy. - the separate linker section sets up naturally for block compression. section compression at build time is practical - how ? include/linux/decompress/generic.h has no corresponding compression - we could drop sites and their storage opportunistically. this could reduce per-site mem by 24/56. Subsystems may not need/want "module:func:line:" in their logs. If they already use format-prefixes such as "drm:kms:", they can select on those, and don't need the site info for that. forex: #> echo module drm format "^drm:kms: " +p >control ie: dynamic_debug_exec_queries("format '^drm:kms: '", "drm"); Once we can map: ddebugs[N] -> ddebug_sites[N], we can: - compress __dyndbg_sites during __init, and mark section __initdata - store the compressed block instead. - decompress on-demand, stream for `cat control` - save chunks of decompressed buffer for enabled callsites - free chunks on site disable, or on memory pressure. Whats actually done here is ths rather mechanical, and preparatory. dynamic_debug.h: I cut struct _ddebug in half, renamed the optional top-half to _ddebug_site, kept __align(8) for both halves. I added a forward decl for a unified comment for both head & body, and added _ddebug.site to point at body. DEFINE_DYNAMIC_DEBUG_METADATA now declares and initializes a 2nd static struct var holding the _ddebug_site, and refs _ddebug to it. dynamic_debug.c: dynamic_debug_init() mem-usage now also counts sites. dynamic_emit_prefix() & ddebug_change() use those moved fields; they get a new initialized auto-var, and the field refs get adjusted as needed to follow the field moves from one struct to the other. struct _ddebug_site *dc = dp->site; ddebug_proc_show() differs slightly; it assigns to (not initializes) the autovar, to avoid a panic when p == SEQ_START_TOKEN. vmlinux.lds.h: add __dyndbg_sites section, with the same align(8) and KEEP as used in the __dyndbg section. Signed-off-by: Jim Cromie --- include/asm-generic/vmlinux.lds.h | 3 +++ include/linux/dynamic_debug.h | 37 +++++++++++++++++--------- lib/dynamic_debug.c | 44 ++++++++++++++++++------------- 3 files changed, 52 insertions(+), 32 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 0331d5d49551..4f2af9de2f03 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -353,6 +353,9 @@ *(__tracepoints) \ /* implement dynamic printk debug */ \ . = ALIGN(8); \ + __start___dyndbg_sites = .; \ + KEEP(*(__dyndbg_sites)) \ + __stop___dyndbg_sites = .; \ __start___dyndbg = .; \ KEEP(*(__dyndbg)) \ __stop___dyndbg = .; \ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dce631e678dd..d56c02ed0c45 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -7,20 +7,28 @@ #endif /* - * An instance of this structure is created in a special - * ELF section at every dynamic debug callsite. At runtime, - * the special section is treated as an array of these. + * A pair of these structs are created in 2 special ELF sections + * (__dyndbg, __dyndbg_sites) for every dynamic debug callsite. + * At runtime, the sections are treated as arrays. */ -struct _ddebug { +struct _ddebug; +struct _ddebug_site { /* - * These fields are used to drive the user interface - * for selecting and displaying debug callsites. + * These fields (and lineno) are used to: + * - decorate log messages per _ddebug.flags + * - select callsites for modification via >control + * - display callsites & settings in `cat control` */ const char *modname; - const char *function; const char *filename; + const char *function; +} __aligned(8); + +struct _ddebug { + struct _ddebug_site *site; + /* format is always needed, lineno shares word with flags */ const char *format; - unsigned int lineno:18; + const unsigned lineno:18; /* * The flags field controls the behaviour at the callsite. * The bits here are changed dynamically when the user @@ -49,8 +57,7 @@ struct _ddebug { struct static_key_false dd_key_false; } key; #endif -} __attribute__((aligned(8))); - +} __aligned(8); #if defined(CONFIG_DYNAMIC_DEBUG_CORE) @@ -88,11 +95,15 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, const char *fmt, ...); #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ - static struct _ddebug __aligned(8) \ - __section("__dyndbg") name = { \ + static struct _ddebug_site __aligned(8) \ + __section("__dyndbg_sites") name##_site = { \ .modname = KBUILD_MODNAME, \ - .function = __func__, \ .filename = __FILE__, \ + .function = __func__, \ + }; \ + static struct _ddebug __aligned(8) \ + __section("__dyndbg") name = { \ + .site = &name##_site, \ .format = (fmt), \ .lineno = __LINE__, \ .flags = _DPRINTK_FLAGS_DEFAULT, \ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 3a7d1f9bcf4d..c1c2c90ed944 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -165,19 +165,20 @@ static int ddebug_change(const struct ddebug_query *query, for (i = 0; i < dt->num_ddebugs; i++) { struct _ddebug *dp = &dt->ddebugs[i]; + struct _ddebug_site *dc = dp->site; /* match against the source filename */ if (query->filename && - !match_wildcard(query->filename, dp->filename) && + !match_wildcard(query->filename, dc->filename) && !match_wildcard(query->filename, - kbasename(dp->filename)) && + kbasename(dc->filename)) && !match_wildcard(query->filename, - trim_prefix(dp->filename))) + trim_prefix(dc->filename))) continue; /* match against the function */ if (query->function && - !match_wildcard(query->function, dp->function)) + !match_wildcard(query->function, dc->function)) continue; /* match against the format */ @@ -214,8 +215,8 @@ static int ddebug_change(const struct ddebug_query *query, #endif dp->flags = newflags; v2pr_info("changed %s:%d [%s]%s =%s\n", - trim_prefix(dp->filename), dp->lineno, - dt->mod_name, dp->function, + trim_prefix(dc->filename), dp->lineno, + dt->mod_name, dc->function, ddebug_describe_flags(dp->flags, &fbuf)); } } @@ -586,12 +587,13 @@ static int remaining(int wrote) return 0; } -static char *__dynamic_emit_prefix(const struct _ddebug *desc, char *buf) +static char *__dynamic_emit_prefix(const struct _ddebug *dp, char *buf) { int pos_after_tid; int pos = 0; + const struct _ddebug_site *desc = dp->site; - if (desc->flags & _DPRINTK_FLAGS_INCL_TID) { + if (dp->flags & _DPRINTK_FLAGS_INCL_TID) { if (in_interrupt()) pos += snprintf(buf + pos, remaining(pos), " "); else @@ -599,15 +601,15 @@ static char *__dynamic_emit_prefix(const struct _ddebug *desc, char *buf) task_pid_vnr(current)); } pos_after_tid = pos; - if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME) + if (dp->flags & _DPRINTK_FLAGS_INCL_MODNAME) pos += snprintf(buf + pos, remaining(pos), "%s:", desc->modname); - if (desc->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) + if (dp->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) pos += snprintf(buf + pos, remaining(pos), "%s:", desc->function); - if (desc->flags & _DPRINTK_FLAGS_INCL_LINENO) + if (dp->flags & _DPRINTK_FLAGS_INCL_LINENO) pos += snprintf(buf + pos, remaining(pos), "%d:", - desc->lineno); + dp->lineno); if (pos - pos_after_tid) pos += snprintf(buf + pos, remaining(pos), " "); if (pos >= PREFIX_SIZE) @@ -884,6 +886,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) { struct ddebug_iter *iter = m->private; struct _ddebug *dp = p; + struct _ddebug_site *dc; struct flagsbuf flags; if (p == SEQ_START_TOKEN) { @@ -892,9 +895,11 @@ static int ddebug_proc_show(struct seq_file *m, void *p) return 0; } + dc = dp->site; + seq_printf(m, "%s:%u [%s]%s =%s \"", - trim_prefix(dp->filename), dp->lineno, - iter->table->mod_name, dp->function, + trim_prefix(dc->filename), dp->lineno, + iter->table->mod_name, dc->function, ddebug_describe_flags(dp->flags, &flags)); seq_escape(m, dp->format, "\t\r\n\""); seq_puts(m, "\"\n"); @@ -1097,17 +1102,17 @@ static int __init dynamic_debug_init(void) return 0; } iter = __start___dyndbg; - modname = iter->modname; + modname = iter->site->modname; iter_start = iter; for (; iter < __stop___dyndbg; iter++) { entries++; - if (strcmp(modname, iter->modname)) { + if (strcmp(modname, iter->site->modname)) { modct++; ret = ddebug_add_module(iter_start, n, modname); if (ret) goto out_err; n = 0; - modname = iter->modname; + modname = iter->site->modname; iter_start = iter; } n++; @@ -1117,9 +1122,10 @@ static int __init dynamic_debug_init(void) goto out_err; ddebug_init_success = 1; - vpr_info("%d modules, %d entries and %d bytes in ddebug tables, %d bytes in __dyndbg section\n", + vpr_info("%d modules, %d entries and %d bytes in ddebug tables, %d bytes in __dyndbg section, %d bytes in __dyndbg_sites section\n", modct, entries, (int)(modct * sizeof(struct ddebug_table)), - (int)(entries * sizeof(struct _ddebug))); + (int)(entries * sizeof(struct _ddebug)), + (int)(entries * sizeof(struct _ddebug_site))); /* apply ddebug_query boot param, dont unload tables on err */ if (ddebug_setup_string[0] != '\0') { From patchwork Tue May 11 18:50:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251837 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 436A2C433B4 for ; Tue, 11 May 2021 18:51:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D7C136191C for ; Tue, 11 May 2021 18:51:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D7C136191C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4D9A36B0075; Tue, 11 May 2021 14:51:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 472346B0078; Tue, 11 May 2021 14:51:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DBA76B007B; Tue, 11 May 2021 14:51:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0208.hostedemail.com [216.40.44.208]) by kanga.kvack.org (Postfix) with ESMTP id 14CCA6B0075 for ; Tue, 11 May 2021 14:51:25 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C878F8E6B for ; Tue, 11 May 2021 18:51:24 +0000 (UTC) X-FDA: 78129843288.24.05B60F4 Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) by imf12.hostedemail.com (Postfix) with ESMTP id 7332E138 for ; Tue, 11 May 2021 18:51:08 +0000 (UTC) Received: by mail-io1-f44.google.com with SMTP id n10so19157270ion.8 for ; Tue, 11 May 2021 11:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NZkviL91C3S/9XGWOAEsFN6SwEwgKBbc6qaVmyj/czk=; b=ht6EjtpH+LwfipsvifQcYTFOoQzDQKwxEEL7FJoNg2SPggbyZlLt6MaRZpkWFUt2iz HHXfeLAWlGcovpiK45++gYuGOtahHTGxLrczNlQOy6ZcTPOHQa0oERsvlmgvenjsMs6c SJ99BUGK8MbxK9N0ZqBjQgFxnJlSSTlEH1sDpasFbHgN3r4Xd7UWRTetiIsRfUMRsoCS VhyGoi1XhL+dXHg8LlsL8n+l83/+uhGmnpY8heRC/gGeL8srVNDtAk04VtUXJgMohVU/ Bbg4l6S9y7YBHiuprhperdYKKGdIYPWpymcOLuL9hZ9FkQEHOz1woh97I85tGPltfbmW 04Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NZkviL91C3S/9XGWOAEsFN6SwEwgKBbc6qaVmyj/czk=; b=GvDhzL3b2/gWjyjkug0pPlXEr9UaI53NXCcwg4/JNrNbfH4iukl6qwItFtZfbnI54c 2f6npjPXpZpNoe/et8UsPT1K0NkgaFtYLej7RBoz20fmy8JVxkPJSzc+9/k1qGyEH1SX nYAee5qNPfF/0DHbqvD1FR5iOw73cUXtvgOObVztK5JVbX09ytpUlfBA7xss3H39QCa1 BKJHksXrDcMOlReKdJbBp97l4YP/XA19qZImaqyo+2WX5bQdau9q0seibeofbraUXI3o FWdaBv7Pdh4KJucsJ2DTEiblOuaivuvV6klevsV+6HOgSR+TwPxXkK3Ro3JORlAZAuji 8VSA== X-Gm-Message-State: AOAM532o0UzeJnwO0Nl5+6vETRonz4dnzh4xeYuJ33N+3QDuam0RBV/c mv/FLSVpQoN3EliLRbvamZy1noSOCItTBA== X-Google-Smtp-Source: ABdhPJxzpAnZ6yyG6y/pP46Oicb8855pCdM+WeFMnHZ4XRPMivf+4zeW3JPkZjxJ20KrXfuAfg8YuA== X-Received: by 2002:a02:b717:: with SMTP id g23mr29183874jam.109.1620759083943; Tue, 11 May 2021 11:51:23 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:23 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 04/28] dyndbg: __init iterate over __dyndbg & __dyndbg_site in parallel Date: Tue, 11 May 2021 12:50:33 -0600 Message-Id: <20210511185057.3815777-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7332E138 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=ht6EjtpH; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.44 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Rspamd-Server: rspam03 X-Stat-Signature: bctkokiahe8idbat8sz7swymp8dhg4ab Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf12; identity=mailfrom; envelope-from=""; helo=mail-io1-f44.google.com; client-ip=209.85.166.44 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759068-620816 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In HEAD~1, a new elf section was added, and dynamic_debug_init() got minimal adjustments; basically s/iter/iter->site/ where needed. Now we rework the for-loop for clarity: . iterate over both sections in parallel (iter & site) . demote iter->site indirection (1st step towards dropping site) . add __(start|stop)___dyndbg_sites decls (init'd in vmlinux.lds.h) . add/rename several iterator/mod_start variables for clarity. . add BUG_ON(iter->site != site) . var rename n to site_ct Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c1c2c90ed944..5a33143215a4 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -41,6 +41,8 @@ extern struct _ddebug __start___dyndbg[]; extern struct _ddebug __stop___dyndbg[]; +extern struct _ddebug_site __start___dyndbg_sites[]; +extern struct _ddebug_site __stop___dyndbg_sites[]; struct ddebug_table { struct list_head link; @@ -118,6 +120,7 @@ do { \ #define vpr_info(fmt, ...) vnpr_info(1, fmt, ##__VA_ARGS__) #define v2pr_info(fmt, ...) vnpr_info(2, fmt, ##__VA_ARGS__) +#define v3pr_info(fmt, ...) vnpr_info(3, fmt, ##__VA_ARGS__) static void vpr_info_dq(const struct ddebug_query *query, const char *msg) { @@ -1086,11 +1089,12 @@ static int __init dynamic_debug_init_control(void) static int __init dynamic_debug_init(void) { - struct _ddebug *iter, *iter_start; + struct _ddebug *iter, *iter_mod_start; + struct _ddebug_site *site, *site_mod_start; const char *modname = NULL; char *cmdline; int ret = 0; - int n = 0, entries = 0, modct = 0; + int site_ct = 0, entries = 0, modct = 0; if (&__start___dyndbg == &__stop___dyndbg) { if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { @@ -1101,23 +1105,29 @@ static int __init dynamic_debug_init(void) ddebug_init_success = 1; return 0; } - iter = __start___dyndbg; - modname = iter->site->modname; - iter_start = iter; - for (; iter < __stop___dyndbg; iter++) { + + iter = iter_mod_start = __start___dyndbg; + site = site_mod_start = __start___dyndbg_sites; + modname = site->modname; + + for (; iter < __stop___dyndbg; iter++, site++) { + + BUG_ON(site != iter->site); entries++; - if (strcmp(modname, iter->site->modname)) { + + if (strcmp(modname, site->modname)) { modct++; - ret = ddebug_add_module(iter_start, n, modname); + ret = ddebug_add_module(iter_mod_start, site_ct, modname); if (ret) goto out_err; - n = 0; - modname = iter->site->modname; - iter_start = iter; + site_ct = 0; + modname = site->modname; + iter_mod_start = iter; + site_mod_start = site; } - n++; + site_ct++; } - ret = ddebug_add_module(iter_start, n, modname); + ret = ddebug_add_module(iter_mod_start, site_ct, modname); if (ret) goto out_err; From patchwork Tue May 11 18:50:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251839 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 1DEADC43460 for ; Tue, 11 May 2021 18:51:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BF8756191C for ; Tue, 11 May 2021 18:51:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF8756191C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 614826B0078; Tue, 11 May 2021 14:51:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 524586B007B; Tue, 11 May 2021 14:51:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 328D68D0001; Tue, 11 May 2021 14:51:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id 18E4B6B0078 for ; Tue, 11 May 2021 14:51:26 -0400 (EDT) Received: from smtpin37.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D06828249980 for ; Tue, 11 May 2021 18:51:25 +0000 (UTC) X-FDA: 78129843330.37.D352675 Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) by imf30.hostedemail.com (Postfix) with ESMTP id 5129CE0011F1 for ; Tue, 11 May 2021 18:50:56 +0000 (UTC) Received: by mail-io1-f50.google.com with SMTP id i7so11698522ioa.12 for ; Tue, 11 May 2021 11:51:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=edbAM8pNMWrl0Zd/ZLYzgEM9CPxsCooD0s2Yg5J4Xik=; b=o/q+Qpd8wiM+S8VNNw4FvN68R7MMHEnj/9Ar6ooVy951E9qwyvXpjNdNe6zHpoINlX z8jVJttCTZID7um6zsJ+n0OW+nJopY7tyGHK+MLvHPu7q8vs7bNAF9Xv69u8nkotqCCb C5N+zUy/fNd2GMp+AWXgAiG1lfMWCZUDMUlxZhbqTzS7FQV89yLDLqCKs2WUPFBVGGNA 6e8JJv/VAIZO5s67UhGLW6bX0jtoFgp9toRKUtIycKrgDuG/I/XFJUC5EcJflkB7IDNv Jmy0id6oXOLXFxubtjCqMj8S7j0iioSSRecsnuA3GUjAadfl84PbZdJuNSBr7FfJ3Ddf 0PtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=edbAM8pNMWrl0Zd/ZLYzgEM9CPxsCooD0s2Yg5J4Xik=; b=AehpfgFD2ELfQlR0r1WnF7G8G86z9AQMGvX5oPOg3MnDutRH9CZwHUSdo5htZrn7uy uWidACfxVueX1F5x2h1sWHe6cMbxd2vRZrmKsdPB8a8B10wTug10O1A5N5A1iySONxDZ JGsBT0U9tYWvU2qXMiKj/qYWvVlgdyr1gvWL+tBdpZoLZMXQcO4a66bl3hfamrhZZA25 PYVq47TLPcgWRPQX7rA3PgssM77eJPjsbeA8bniOOyf6kQ8U3yu/bfKLiC23cCHDHrCY ex0W2X7m4iFBN9Uyf8i0Jv5oMd8RJmNNayudS9uPGQekKUUywMkQqw6KjavsjEMyJidp gIXg== X-Gm-Message-State: AOAM533HOoGV5zW+E0hul9SuWaN4VowAUCrqu5QGFV8zdsTLPxjZdlGu pXX5iATrXVM01RFWCjdmpL4= X-Google-Smtp-Source: ABdhPJy/LBlcvLqRCMyyl1Jzgkwgsb71H5OvnqlkY4P+e1/3kWWKv5zaTdow/4t+NTf857Bnd4iIaQ== X-Received: by 2002:a02:54c1:: with SMTP id t184mr19223588jaa.79.1620759084933; Tue, 11 May 2021 11:51:24 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:24 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 05/28] dyndbg: refactor part of ddebug_change to ddebug_match_site Date: Tue, 11 May 2021 12:50:34 -0600 Message-Id: <20210511185057.3815777-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b="o/q+Qpd8"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf30.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.50 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Stat-Signature: 3j66jpqhqe557k93cnphbeybqnboppie X-Rspamd-Queue-Id: 5129CE0011F1 X-Rspamd-Server: rspam02 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf30; identity=mailfrom; envelope-from=""; helo=mail-io1-f50.google.com; client-ip=209.85.166.50 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759056-249384 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Move all the site-match logic into a separate function, reindent the code, and replace the continues with return falses. No functional changes. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 75 ++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 5a33143215a4..e6e2cb0180e5 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -142,6 +142,48 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg) query->first_lineno, query->last_lineno); } +static int ddebug_match_site(const struct ddebug_query *query, + const struct _ddebug *dp) +{ + struct _ddebug_site *dc = dp->site; + + /* match against the source filename */ + if (query->filename && + !match_wildcard(query->filename, dc->filename) && + !match_wildcard(query->filename, + kbasename(dc->filename)) && + !match_wildcard(query->filename, + trim_prefix(dc->filename))) + return false; + + /* match against the function */ + if (query->function && + !match_wildcard(query->function, dc->function)) + return false; + + /* match against the format */ + if (query->format) { + if (*query->format == '^') { + char *p; + /* anchored search. match must be at beginning */ + p = strstr(dp->format, query->format+1); + if (p != dp->format) + return false; + } else if (!strstr(dp->format, query->format)) + return false; + } + + /* match against the line number range */ + if (query->first_lineno && + dp->lineno < query->first_lineno) + return false; + if (query->last_lineno && + dp->lineno > query->last_lineno) + return false; + + return true; +} + /* * Search the tables for _ddebug's which match the given `query' and * apply the `flags' and `mask' to them. Returns number of matching @@ -170,38 +212,7 @@ static int ddebug_change(const struct ddebug_query *query, struct _ddebug *dp = &dt->ddebugs[i]; struct _ddebug_site *dc = dp->site; - /* match against the source filename */ - if (query->filename && - !match_wildcard(query->filename, dc->filename) && - !match_wildcard(query->filename, - kbasename(dc->filename)) && - !match_wildcard(query->filename, - trim_prefix(dc->filename))) - continue; - - /* match against the function */ - if (query->function && - !match_wildcard(query->function, dc->function)) - continue; - - /* match against the format */ - if (query->format) { - if (*query->format == '^') { - char *p; - /* anchored search. match must be at beginning */ - p = strstr(dp->format, query->format+1); - if (p != dp->format) - continue; - } else if (!strstr(dp->format, query->format)) - continue; - } - - /* match against the line number range */ - if (query->first_lineno && - dp->lineno < query->first_lineno) - continue; - if (query->last_lineno && - dp->lineno > query->last_lineno) + if (!ddebug_match_site(query, dp)) continue; nfound++; From patchwork Tue May 11 18:50:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251841 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 126ABC433B4 for ; Tue, 11 May 2021 18:51:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B6D5461166 for ; Tue, 11 May 2021 18:51:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6D5461166 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 240E56B007B; Tue, 11 May 2021 14:51:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CD358D0001; Tue, 11 May 2021 14:51:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F35A66B007E; Tue, 11 May 2021 14:51:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0092.hostedemail.com [216.40.44.92]) by kanga.kvack.org (Postfix) with ESMTP id D738E6B007B for ; Tue, 11 May 2021 14:51:26 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9F7855832 for ; Tue, 11 May 2021 18:51:26 +0000 (UTC) X-FDA: 78129843372.25.A783358 Received: from mail-io1-f48.google.com (mail-io1-f48.google.com [209.85.166.48]) by imf19.hostedemail.com (Postfix) with ESMTP id 173FD90009EC for ; Tue, 11 May 2021 18:50:52 +0000 (UTC) Received: by mail-io1-f48.google.com with SMTP id i7so11698557ioa.12 for ; Tue, 11 May 2021 11:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=D992vbjQHx6507pkKz07GBRojC3qb4kG7bKEZ05x9do=; b=HD/GXFSooFNbTEqtrlLNxCJxchPcIr385FVGf3X/Plk9rqXjc5RLPbR6I+C9c+dLpp 6iHhy5WxZx6PXgVl34SoiJtxjfbmrF1R8AGe/sKGy2XmQUjX6q1el3pXa/mJ2RxHACkn QR95INsZUwonxFhJvv2M1bLRaNqNruGIfOP4ud3Mo5x/gNBMR0W46yi1xcl/F50vMeGZ xwOezAjBWuIMT8X6lhoUDrS1chsFHbfRslaZazA8uFp9XncLnU0fEAeC2zQJkSW18DKq f2twe6qNBOcA7QadZTNqASdKtvTqWz0tjd273L6CiVhdwsZqQYhB7B6/HBXmjDW6gsY0 S9NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D992vbjQHx6507pkKz07GBRojC3qb4kG7bKEZ05x9do=; b=hyXptuvKso6K90LpbOgbpaYO/DvOdcOb01BApnrbV2i33OEodcNnu8MRrpiDKHE65R tvEbrZhkDLU68hoL76dakOGbTGZBWDEeo3ZuGxrW/RoU7YkZC6UL9hPaReegCsxmdDU/ qGoBuzDPBEwa4DoGn0ch/Kn+YzXh2sY1h077XePd0ahBxlShOXg4xAyDC8h/XXs4XAkS iWCE/iyaiQOjRDIqZSXTuerQs3rl/0n/kW/fePNvSm5eaqfGV1U1JohfH/XtZLpnp7YL 0d952qWGyTUnVodi1wFZ+h3dREtd8F6Rf4c5Wy1sXES+q8sPMqzuwHZO9E8IYtw+oBA5 9udg== X-Gm-Message-State: AOAM531tqg7YFO2kKdwsbNpIkhtgqcEcPQwNcb6mpjflHYabraki9mla mdTpJGymtwpVOcSllivK/KL3uv3YjC8oEw== X-Google-Smtp-Source: ABdhPJz+/HAjdG2DVizQ9q+xdlKi2ro3RWcx7IQiCkjgVWPiXePtmnS39w0/eb4eV3F1fIvjZKvh6A== X-Received: by 2002:a05:6638:d15:: with SMTP id q21mr972818jaj.83.1620759085793; Tue, 11 May 2021 11:51:25 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:25 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 06/28] dyndbg: accept null site in ddebug_match_site Date: Tue, 11 May 2021 12:50:35 -0600 Message-Id: <20210511185057.3815777-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b="HD/GXFSo"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.48 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Stat-Signature: pmkezz993afawcogsjqcsmnfae8ocqa9 X-Rspamd-Queue-Id: 173FD90009EC X-Rspamd-Server: rspam02 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf19; identity=mailfrom; envelope-from=""; helo=mail-io1-f48.google.com; client-ip=209.85.166.48 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759052-305796 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Since all query terms must be satisfied, we can reorder for clarity, moving !!site dependent checks after those on _ddebug itself. 1- move format and line-number check code to the top of the function, since they don't use/check site info. 2- test site pointer: If its null, we return early, skipping 3: If the query tests against missing site info, fail the match. otherwize site matches. 3- rest of function (checking site vs query) is unchanged. ddebug_match_site ignores module, because it's tested already by the caller, where it is known from debug_tables. no functional changes Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index e6e2cb0180e5..47d427b82ae1 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -145,21 +145,7 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg) static int ddebug_match_site(const struct ddebug_query *query, const struct _ddebug *dp) { - struct _ddebug_site *dc = dp->site; - - /* match against the source filename */ - if (query->filename && - !match_wildcard(query->filename, dc->filename) && - !match_wildcard(query->filename, - kbasename(dc->filename)) && - !match_wildcard(query->filename, - trim_prefix(dc->filename))) - return false; - - /* match against the function */ - if (query->function && - !match_wildcard(query->function, dc->function)) - return false; + struct _ddebug_site *dc; /* match against the format */ if (query->format) { @@ -181,6 +167,29 @@ static int ddebug_match_site(const struct ddebug_query *query, dp->lineno > query->last_lineno) return false; + dc = dp->site; + if (!dc) { + /* site info has been dropped, so query cannot test these fields */ + if (query->filename || query->function) + return false; + else + return true; + } + + /* match against the source filename */ + if (query->filename && + !match_wildcard(query->filename, dc->filename) && + !match_wildcard(query->filename, + kbasename(dc->filename)) && + !match_wildcard(query->filename, + trim_prefix(dc->filename))) + return false; + + /* match against the function */ + if (query->function && + !match_wildcard(query->function, dc->function)) + return false; + return true; } @@ -210,7 +219,7 @@ static int ddebug_change(const struct ddebug_query *query, for (i = 0; i < dt->num_ddebugs; i++) { struct _ddebug *dp = &dt->ddebugs[i]; - struct _ddebug_site *dc = dp->site; + struct _ddebug_site *dc; if (!ddebug_match_site(query, dp)) continue; From patchwork Tue May 11 18:50:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251843 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 2B22CC433B4 for ; Tue, 11 May 2021 18:51:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C04C861185 for ; Tue, 11 May 2021 18:51:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C04C861185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3773D6B007D; Tue, 11 May 2021 14:51:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 328816B007E; Tue, 11 May 2021 14:51:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1CBEE6B0080; Tue, 11 May 2021 14:51:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0147.hostedemail.com [216.40.44.147]) by kanga.kvack.org (Postfix) with ESMTP id F2D9F6B007D for ; Tue, 11 May 2021 14:51:27 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A7B5F181AEF3F for ; Tue, 11 May 2021 18:51:27 +0000 (UTC) X-FDA: 78129843414.05.D2DB54A Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) by imf09.hostedemail.com (Postfix) with ESMTP id 0537160006EB for ; Tue, 11 May 2021 18:51:15 +0000 (UTC) Received: by mail-io1-f45.google.com with SMTP id n10so19157403ion.8 for ; Tue, 11 May 2021 11:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XoeV1CIyKryeNzxxt5mlrf/4FcTSldzarEqWBQPGNdM=; b=jiMcXG4zKPDWdEDeFEfp7Wxzaoya/ZEkEcM9vBOGps7AKUfCKS4UV/tMiAOvCtVG1F 69GNW/TyDoFvqKkgS59LI/zcZPmd18pJdgxuY6XrlzkHnqgPB9O1K/yyllhsYbT55GbC Ljzz31TRhCibHIaj8XP/VYqif/02Iwe3XElm157hVmjNQM4Tc0JrvjtT/xo5VYf35F+l sqnoHQEPplWTAO7j/goCj9FIE0q3xFMy0YSilDHdDNQ+ViWqmHaIp4n90iJMGvMkD3Xr rJG+Nyk9xXyARYU1wDoHVdMQHL6vypuMVt9pC3S1TeRcBKeujcP3ISpy9lGYcdK4Fi2n pW9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XoeV1CIyKryeNzxxt5mlrf/4FcTSldzarEqWBQPGNdM=; b=jriIAxieIM+HO6CoHXMAgDpraSPBZ7yX81SKttoceDVTACUy9bUc1YsoCjsBzBX8Cb rQ8asChPnpsUu+y0lxM/fUbWdH8DpGWUBKhBoMS3c/4VUB0GF4642Lkid5gUcLUAutFp AosbQS8gL46YmbqaOFdiATjBB5uDAoqY3rFbbGRh42E3xBJbkF4U5yQusNfzwuBh/35O N94JagPNvDDLHemDpknK+tmmslD+XMsmgdYTo03OsOb1fTiV7NETlVkpWMXF/emuj8jM kkxO+ZQEkDQmzKiKO/w5Pdp9JD50u5BxWglB1vf1Rh1tlBeghV6O13E9m/+Qmv4/AsOb MtYA== X-Gm-Message-State: AOAM532eBmNUvjeygXPuF3PgGr1jrg69m+fdnOBv2zTdWF2A/JGDL3TJ 9yOoMGeBGhBcjJrF9xkTKyI= X-Google-Smtp-Source: ABdhPJzT38saFp5RPxsUsgX8AOZfspvCsMbU8J/sSMPLhxAy9yKP0XWHcUJeYPZURWh98vWkeTvIFg== X-Received: by 2002:a6b:6c18:: with SMTP id a24mr23927594ioh.21.1620759086691; Tue, 11 May 2021 11:51:26 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:26 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 07/28] dyndbg: hoist ->site out of ddebug_match_site Date: Tue, 11 May 2021 12:50:36 -0600 Message-Id: <20210511185057.3815777-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=jiMcXG4z; spf=pass (imf09.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.45 as permitted sender) smtp.mailfrom=jimcromie@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 0537160006EB X-Stat-Signature: hyb6g6i7ihakax4p6ipwjqcpcwrkrdi5 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf09; identity=mailfrom; envelope-from=""; helo=mail-io1-f45.google.com; client-ip=209.85.166.45 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759075-954426 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: A coming change adds _get/_put abstraction on the site pointer, to allow managing site info more flexibly. The get/put pattern is best done at a single lexical scope, where its more obviously correct, so hoist the ->site ref out of ddebug_match_site, and pass it in instead. no functional changes Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 47d427b82ae1..0896c681db40 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -143,10 +143,9 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg) } static int ddebug_match_site(const struct ddebug_query *query, - const struct _ddebug *dp) + const struct _ddebug *dp, + const struct _ddebug_site *dc) { - struct _ddebug_site *dc; - /* match against the format */ if (query->format) { if (*query->format == '^') { @@ -167,7 +166,6 @@ static int ddebug_match_site(const struct ddebug_query *query, dp->lineno > query->last_lineno) return false; - dc = dp->site; if (!dc) { /* site info has been dropped, so query cannot test these fields */ if (query->filename || query->function) @@ -219,9 +217,9 @@ static int ddebug_change(const struct ddebug_query *query, for (i = 0; i < dt->num_ddebugs; i++) { struct _ddebug *dp = &dt->ddebugs[i]; - struct _ddebug_site *dc; + struct _ddebug_site *dc = dp->site; - if (!ddebug_match_site(query, dp)) + if (!ddebug_match_site(query, dp, dc)) continue; nfound++; From patchwork Tue May 11 18:50:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251845 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 E5A1DC43460 for ; Tue, 11 May 2021 18:51:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 82629611AE for ; Tue, 11 May 2021 18:51:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82629611AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 49B0D6B007E; Tue, 11 May 2021 14:51:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 408C06B0080; Tue, 11 May 2021 14:51:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0F3C6B0081; Tue, 11 May 2021 14:51:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id B74AA6B007E for ; Tue, 11 May 2021 14:51:28 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 66311180BDF39 for ; Tue, 11 May 2021 18:51:28 +0000 (UTC) X-FDA: 78129843456.36.9CFE347 Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) by imf02.hostedemail.com (Postfix) with ESMTP id A12A540002C0 for ; Tue, 11 May 2021 18:50:54 +0000 (UTC) Received: by mail-il1-f174.google.com with SMTP id h6so18057240ila.7 for ; Tue, 11 May 2021 11:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pNVEKTV+bvX9RYRh1tpVpNIQOxEufSB06uqOG2WwH4Q=; b=a5o/kgEGGAE9GtWt+aT2/FVLQzbZlWlMuA82ZmTbVDKaRdPdnRB6JjdNn1PzNRoG0p uAirF11C6ytPQhCoETeJ50hKUY8JO6L3q7FCuxLPNSNHqlGQmeQRUfuzXYgJorWul0a5 5x+7v5NmxvEWcMEkDm2zS8iJgWUxFS9bjyKT7AtEy5A4ROf7uvjMhZR+DZV6J0GlEAsR WiQYZOP7az0fOBjHp89siBspatBjwY2OolcmebzeBY27FA+fkNILDsFM4voXiEqBcBRP mL4MWeer41/WpdfiajXCcbQzMnEt3IjrzLRPnNj1WzRnzdSI9xITakte7M9+emqSibml yKOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pNVEKTV+bvX9RYRh1tpVpNIQOxEufSB06uqOG2WwH4Q=; b=H/nGoDfAUspXlpLWAGmaV54NUhsjmVFyT8lj3hZoOgXAGVXerpTrTIpuANhz1fxGwh vgblNzb4A98D5sH0h1h/DOns5b0hHLTEbuCqtJbMiPt2Djo5ZYura/hca0MAdpw0h07N HdCc2Ex9/NiFyHmqTlF6hGcJyV8NqCFYBvI57KU7/HnwJRWbvNVxq3gKF3SzJcsqB+MO pKIZ7GUfTWL7AwGNh+CLJvk+q3AENx+rdD2mlVRLy67S96o3FQTxRtbymPKnW4AQDMhI MFXvdt5qk44+LTe0rbrfBEVJNspDNdhSfmea9E9Gqw8bJQ62LYKL1rhiNFgsmSKFqBwW fKZg== X-Gm-Message-State: AOAM533qnw4hkkBCbrIPzuoOQpGC9d4SllMR75shHYjm3AOxUdbvTNQ3 PRuGIDpVemCbvD5Xpq4mmck= X-Google-Smtp-Source: ABdhPJw8w6k8eSf/FzYnXUHbsHEhp5PxB2/26GnevLxHvuWwhqTmTCXwYS/ZqRxeHjytBZrv1bd36g== X-Received: by 2002:a05:6e02:12b3:: with SMTP id f19mr28257289ilr.219.1620759087554; Tue, 11 May 2021 11:51:27 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:27 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 08/28] dyndbg: accept null site in ddebug_change Date: Tue, 11 May 2021 12:50:37 -0600 Message-Id: <20210511185057.3815777-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b="a5o/kgEG"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.174 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Stat-Signature: dbshysomxryksxrntro6b5k5uznyg9mz X-Rspamd-Queue-Id: A12A540002C0 X-Rspamd-Server: rspam02 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf02; identity=mailfrom; envelope-from=""; helo=mail-il1-f174.google.com; client-ip=209.85.166.174 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759054-107135 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: fix a debug-print that includes site info, by adding an alternate debug message that does not. no functional changes. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 0896c681db40..fa89d69dad4e 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -235,10 +235,17 @@ static int ddebug_change(const struct ddebug_query *query, static_branch_enable(&dp->key.dd_key_true); #endif dp->flags = newflags; - v2pr_info("changed %s:%d [%s]%s =%s\n", - trim_prefix(dc->filename), dp->lineno, - dt->mod_name, dc->function, - ddebug_describe_flags(dp->flags, &fbuf)); + + if (dc) + v2pr_info("changed %s:%d [%s]%s =%s\n", + trim_prefix(dc->filename), dp->lineno, + dt->mod_name, dc->function, + ddebug_describe_flags(dp->flags, &fbuf)); + else + v2pr_info("changed %s:%d =%s \"%s\"\n", + dt->mod_name, dp->lineno, + ddebug_describe_flags(dp->flags, &fbuf), + dp->format); } } mutex_unlock(&ddebug_lock); From patchwork Tue May 11 18:50:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251847 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 82BAFC433ED for ; Tue, 11 May 2021 18:51:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1A62A611AB for ; Tue, 11 May 2021 18:51:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A62A611AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 88B086B0080; Tue, 11 May 2021 14:51:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BC166B0083; Tue, 11 May 2021 14:51:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20C1E6B0082; Tue, 11 May 2021 14:51:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by kanga.kvack.org (Postfix) with ESMTP id A9D226B0081 for ; Tue, 11 May 2021 14:51:29 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 602A91801C5D8 for ; Tue, 11 May 2021 18:51:29 +0000 (UTC) X-FDA: 78129843498.06.E3AB862 Received: from mail-il1-f180.google.com (mail-il1-f180.google.com [209.85.166.180]) by imf30.hostedemail.com (Postfix) with ESMTP id DB176E002011 for ; Tue, 11 May 2021 18:50:59 +0000 (UTC) Received: by mail-il1-f180.google.com with SMTP id h6so18057279ila.7 for ; Tue, 11 May 2021 11:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gKUtj5xFpWrKHzfDwNn5dlfDWlNqWpU9zICKw/jFmZs=; b=CVrTPF2f0gSY3Mvjt3pelxNj53ot8zdyqZZbTQfRWrMBJp19Qxqm4SKP88OW7uKbfY 1HkgbTi2YK8eFOzk+PtWsULQP0gfQpauVrXbOPpyPiKb6GxsS1FF9aF7lDJqE2AeJ9bY C0A1Y5nzZehb5W38XwDPVgk1wI3WttvaoNfysLa+5sxU8zMCprgcWHs6OU7wLb92ocmB ge01Jgh40m+zG/NecEml74/4mIjVnOH9iMgxSA6fGBxD1/1/RSZCpEijyh8ETtXLpra9 GX4JGfqmj9ivdd6ys5386kxDpjDATJjv7SS8n/ZttZFRARae/qIv9HPiP0Rg6Fzy/LOX TKtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gKUtj5xFpWrKHzfDwNn5dlfDWlNqWpU9zICKw/jFmZs=; b=cuu6IwsqY73aQX46PWWHgzKzgC2tvpZDyx0/EwBPlp8xc8nc9JAB+scsDWZjbuiPOu HqJpulwjh9+rtdhyYX3XN5do/IMJOMxwEQ0zLTRr+hO6hpyPrDh9CXXO3M6CifCYxSqt BNn2ec0wPBzAzPQkYMx4VhT3vWg/EcwCRjhErjvXForR1CxM3HrHaVTC4+lQan8FMZ4p 8Y8tf3uDJvOMkgbZIXV/6Cx9XZf7+C1LZrlyHOfqyWl19P3KioTkc28EsbXQOwBP2CG9 RuJO7cM05mZh5N5juyyiqTM7iDoD/ZdRXBEmXiuCmpKvIo5cX5xCCNufv4FV+Tlmcmfs CsVQ== X-Gm-Message-State: AOAM530GHjYgPJzGJmQd0zshJyZj0zERVrL0PLkRSEPvU+89fDL2aBSb 5uC1qoyJ65hdud5hNr/mHHlm63jHDeJS/w== X-Google-Smtp-Source: ABdhPJyVXABAr/pZSxRKQedughfiD2JS/O36Hv2xerHpCrNdA+O895Nnd5Y6s3T4zAGL9M3Vubxgiw== X-Received: by 2002:a92:c50c:: with SMTP id r12mr27664795ilg.281.1620759088517; Tue, 11 May 2021 11:51:28 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:28 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 09/28] dyndbg: accept null site in dynamic_emit_prefix Date: Tue, 11 May 2021 12:50:38 -0600 Message-Id: <20210511185057.3815777-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: DB176E002011 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=CVrTPF2f; spf=pass (imf30.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.180 as permitted sender) smtp.mailfrom=jimcromie@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Stat-Signature: 6n5o6akwczks318djiczqsq16e8egemg Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf30; identity=mailfrom; envelope-from=""; helo=mail-il1-f180.google.com; client-ip=209.85.166.180 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759059-711006 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 2 prints use site->member, protect them with if site. no functional changes. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index fa89d69dad4e..fb8547feb061 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -629,15 +629,19 @@ static char *__dynamic_emit_prefix(const struct _ddebug *dp, char *buf) task_pid_vnr(current)); } pos_after_tid = pos; - if (dp->flags & _DPRINTK_FLAGS_INCL_MODNAME) - pos += snprintf(buf + pos, remaining(pos), "%s:", - desc->modname); - if (dp->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) - pos += snprintf(buf + pos, remaining(pos), "%s:", - desc->function); + + if (desc) { + if (dp->flags & _DPRINTK_FLAGS_INCL_MODNAME) + pos += snprintf(buf + pos, remaining(pos), "%s:", + desc->modname); + if (dp->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) + pos += snprintf(buf + pos, remaining(pos), "%s:", + desc->function); + } if (dp->flags & _DPRINTK_FLAGS_INCL_LINENO) pos += snprintf(buf + pos, remaining(pos), "%d:", dp->lineno); + if (pos - pos_after_tid) pos += snprintf(buf + pos, remaining(pos), " "); if (pos >= PREFIX_SIZE) From patchwork Tue May 11 18:50:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251849 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 46DDCC433B4 for ; Tue, 11 May 2021 18:51:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D7A4861935 for ; Tue, 11 May 2021 18:51:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D7A4861935 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 45BA76B0081; Tue, 11 May 2021 14:51:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1260E6B0082; Tue, 11 May 2021 14:51:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A80416B0085; Tue, 11 May 2021 14:51:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id 7239A6B0081 for ; Tue, 11 May 2021 14:51:30 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 39826181AEF3F for ; Tue, 11 May 2021 18:51:30 +0000 (UTC) X-FDA: 78129843540.23.E35CFC6 Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) by imf25.hostedemail.com (Postfix) with ESMTP id A10EE600010F for ; Tue, 11 May 2021 18:51:21 +0000 (UTC) Received: by mail-il1-f171.google.com with SMTP id j20so18028099ilo.10 for ; Tue, 11 May 2021 11:51:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A7hQGSQuKR4sAj9RAyVubeatxnEwd+8g9Z/5RIBV+x4=; b=LAl6WYqQ5oNZ+/ftE8WCTgl6PWkHtm5wTyxt9+bKNDbB0+GdFJWNEC0BfvPDdGZFEa 1VfKdclNchgDTw6/+YwScmO6R0/VYnUqp4/GWudQO4WzTTFN9NNEHOmhSKeqyAe9P+0P 2O09xfPaMSuxljzBQz0/ED22HSxrMzqOUvM1RlRvy/kwnkF8D2JLhZ1wQiTMG0xjROXR iQEQZ8qH59sTK4sVyHCC/yyljM2iUaNyq/i1hA6w6odH1lOQIEh4dr+sj0MqH7w28UMe 3JTleZcEdkf0GSoLkaiORK/+TSl5ARzzyYaI1dlubqtUf9BeM5clPsbJ6P+JQi77xJ7i DciQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A7hQGSQuKR4sAj9RAyVubeatxnEwd+8g9Z/5RIBV+x4=; b=o+dRrOiOdbCHkkiGbnxTWBkVTo+MMkHcV5T512nhpfE+54q3YA2OeBt33EHXEcp4aN UwXQLg5EO62LzogZ2TZXvBzM/7QOLFPbw0Tojagbae/a76XjtcS9JubDPBD4QLSTrFor 7i7EofBdh9XRq60mARlVOzPs8N4sFw0XCgTf2lZEIH3qtadhDkv0ZsINz+Ehn1Cgs8Kd e9AzLpEu3UwU9dhtn76GiZ7TyaVNBd9tw1BnVBePq0fF1jMHt3WhE7r5HUH8+pnNzh/p YuZfZQqpqgGV3f4J4jl6B75LsNuLSF0eTULGPaNRCKkQuJDjlxUyC6mhbeeyI/sVzIjb yVNA== X-Gm-Message-State: AOAM533o9tjkSg/aYboQNAHIKj5FdnZmIFechznbOvK+XTyEBm7ZC5mf LlX3yYMdSxyeybMEgUP0yfE= X-Google-Smtp-Source: ABdhPJz5vY3J4iH6mxxGAcckjD1E3A+hfMKv1yCPzUuGXaAllWJ0VEdlszZaY+BOi6QtjCMCrX9mpg== X-Received: by 2002:a92:b711:: with SMTP id k17mr17595756ili.210.1620759089375; Tue, 11 May 2021 11:51:29 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:29 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 10/28] dyndbg: accept null site in ddebug_proc_show Date: Tue, 11 May 2021 12:50:39 -0600 Message-Id: <20210511185057.3815777-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=LAl6WYqQ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.171 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Stat-Signature: egq9y6hj7pg55f4pknchnj7y7rj83a74 X-Rspamd-Queue-Id: A10EE600010F X-Rspamd-Server: rspam02 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf25; identity=mailfrom; envelope-from=""; helo=mail-il1-f171.google.com; client-ip=209.85.166.171 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759081-208783 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Accept a ddebug record with a null site pointer, and write abbreviated output for that record that doesn't include site info (but does include line-number, since that can be used in >control queries). Also add a 2nd header line with a template for the new output. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index fb8547feb061..5faf49054b1d 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -923,18 +923,27 @@ static int ddebug_proc_show(struct seq_file *m, void *p) if (p == SEQ_START_TOKEN) { seq_puts(m, - "# filename:lineno [module]function flags format\n"); + "#: filename:lineno [module]function flags format\n" + "#| [module]:lineno flags format\n" + ); return 0; } dc = dp->site; - - seq_printf(m, "%s:%u [%s]%s =%s \"", - trim_prefix(dc->filename), dp->lineno, - iter->table->mod_name, dc->function, - ddebug_describe_flags(dp->flags, &flags)); - seq_escape(m, dp->format, "\t\r\n\""); - seq_puts(m, "\"\n"); + if (dc) { + seq_printf(m, "%s:%u [%s]%s =%s \"", + trim_prefix(dc->filename), dp->lineno, + iter->table->mod_name, dc->function, + ddebug_describe_flags(dp->flags, &flags)); + seq_escape(m, dp->format, "\t\r\n\""); + seq_puts(m, "\"\n"); + } else { + seq_printf(m, "[%s]:%u =%s \"", + iter->table->mod_name, dp->lineno, + ddebug_describe_flags(dp->flags, &flags)); + seq_escape(m, dp->format, "\t\r\n\""); + seq_puts(m, "\"\n"); + } return 0; } From patchwork Tue May 11 18:50:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251851 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 E3AD3C43461 for ; Tue, 11 May 2021 18:51:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7F3FF611AE for ; Tue, 11 May 2021 18:51:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F3FF611AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 611426B0082; Tue, 11 May 2021 14:51:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DC456B0083; Tue, 11 May 2021 14:51:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6A836B0087; Tue, 11 May 2021 14:51:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0220.hostedemail.com [216.40.44.220]) by kanga.kvack.org (Postfix) with ESMTP id A89646B0083 for ; Tue, 11 May 2021 14:51:31 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 5C0F4181AEF3F for ; Tue, 11 May 2021 18:51:31 +0000 (UTC) X-FDA: 78129843582.06.5EE4A55 Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) by imf28.hostedemail.com (Postfix) with ESMTP id 8DF9C2000264 for ; Tue, 11 May 2021 18:51:29 +0000 (UTC) Received: by mail-il1-f177.google.com with SMTP id z1so10201643ils.0 for ; Tue, 11 May 2021 11:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nhCiWTrLaek2l7vUen81GgzaKiSCRGwtP17K82jei8A=; b=Yhx1L10EEQDF9KD2LDl5eJfcnHTASJESzEYK0s/A3gNp+lePUTEQT1LFN8Mj73dwiK g49vxxv+ybCQQALpP5kuMlnYjVnD7TW6QZks5w8gLmJTuGl5BpbZGoCSVFtXOpvbSbKM qYHm7CLaJq021V4cJglqkml/tZkmzs/BpnIA0UdUGvXEgOO8ucgA1jGxUKtqrkZxVSCD KojoHWyyUEWVAiBVrZ0iD0Qr/PbA/dPs0Runf+Tgvd1/oRfe2q0YYN6wGLWnHALm5et/ qJhA87XYL42lICWQS2g89yG0x+jgaXx/Oqw5fUpliLuPglH52kA3fxwcRyB9hCg396hO LIyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nhCiWTrLaek2l7vUen81GgzaKiSCRGwtP17K82jei8A=; b=WzFuSDsdt1vfcCOazjTFOkcvXmr59TPDUq43iZg+En8wjC8WdrQX2cE2nZJ7RRhJbe KU3B28w+xuhvPzYS3M0Jc9yUOBtORqexF8jEhlRZaXFyInPsCCwI/qr3csi7EyT7Onpv MwmTqzh13zC2fnGEPnWBTTSzDUhHCV+0rAMUITD6ydBHvw7YuEsKpcvy5Q5w8O8ZNvWE uJKlfvgVx90yCmkoM7mhkpwOmC9dAG9fxToiRxub5DoQnx5ToSBYOIZvd0u9kvaaoS9d K0gMS97+25R9OdOdsd0ofgWv9obj7OzP4qNh64+jmhwWkGf+EEjP6DlWLPIT3J1b3mRP qasQ== X-Gm-Message-State: AOAM531ApBaPVUh3BrtqnOl3eajQ1mIfNHlwubsY7Pjw8MDR0LrdaLfZ DwnvwPyhijd0o1hwRtbOeo4= X-Google-Smtp-Source: ABdhPJw0bBk5w3RUzzAen2n0A4ZC46f1p52jWlNLNunZfi+6JyH1Sp29JsV5c3WV+JHeDh4c01tL1w== X-Received: by 2002:a05:6e02:80b:: with SMTP id u11mr28566931ilm.153.1620759090309; Tue, 11 May 2021 11:51:30 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:29 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 11/28] dyndbg: refactor ddebug_alter_site out of ddebug_change Date: Tue, 11 May 2021 12:50:40 -0600 Message-Id: <20210511185057.3815777-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8DF9C2000264 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=Yhx1L10E; spf=pass (imf28.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.177 as permitted sender) smtp.mailfrom=jimcromie@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Stat-Signature: nuxij87kb7nk6ztb9pd6yhi86jifjbx6 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf28; identity=mailfrom; envelope-from=""; helo=mail-il1-f177.google.com; client-ip=209.85.166.177 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759089-508576 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Move the JUMP_LABEL/static-key code to a separate function. no functional changes. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 5faf49054b1d..a4ddafdbd9a1 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -191,6 +191,18 @@ static int ddebug_match_site(const struct ddebug_query *query, return true; } +static void ddebug_alter_site(struct _ddebug *dp, + struct flag_settings *modifiers) +{ +#ifdef CONFIG_JUMP_LABEL + if (dp->flags & _DPRINTK_FLAGS_PRINT) { + if (!(modifiers->flags & _DPRINTK_FLAGS_PRINT)) + static_branch_disable(&dp->key.dd_key_true); + } else if (modifiers->flags & _DPRINTK_FLAGS_PRINT) + static_branch_enable(&dp->key.dd_key_true); +#endif +} + /* * Search the tables for _ddebug's which match the given `query' and * apply the `flags' and `mask' to them. Returns number of matching @@ -227,13 +239,9 @@ static int ddebug_change(const struct ddebug_query *query, newflags = (dp->flags & modifiers->mask) | modifiers->flags; if (newflags == dp->flags) continue; -#ifdef CONFIG_JUMP_LABEL - if (dp->flags & _DPRINTK_FLAGS_PRINT) { - if (!(modifiers->flags & _DPRINTK_FLAGS_PRINT)) - static_branch_disable(&dp->key.dd_key_true); - } else if (modifiers->flags & _DPRINTK_FLAGS_PRINT) - static_branch_enable(&dp->key.dd_key_true); -#endif + + ddebug_alter_site(dp, modifiers); + dp->flags = newflags; if (dc) From patchwork Tue May 11 18:50:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251853 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 B2103C43462 for ; Tue, 11 May 2021 18:51:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4C7F461879 for ; Tue, 11 May 2021 18:51:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C7F461879 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A55F16B0083; Tue, 11 May 2021 14:51:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A2EB78D0001; Tue, 11 May 2021 14:51:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CD786B0087; Tue, 11 May 2021 14:51:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0091.hostedemail.com [216.40.44.91]) by kanga.kvack.org (Postfix) with ESMTP id 709216B0085 for ; Tue, 11 May 2021 14:51:32 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 330C2ABF3 for ; Tue, 11 May 2021 18:51:32 +0000 (UTC) X-FDA: 78129843624.16.C2EFD4D Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) by imf26.hostedemail.com (Postfix) with ESMTP id D86F44080F78 for ; Tue, 11 May 2021 18:51:17 +0000 (UTC) Received: by mail-il1-f169.google.com with SMTP id h6so18057388ila.7 for ; Tue, 11 May 2021 11:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vrCRdPvqXLwfcbFZbk4xQpB3sIke8Dnzk1UweHKnIBI=; b=dRr3KBsHvvPSrSla5VPoixzJBzTf66tdvr8gPMUovf9iq5F56zOW/lEq6odKFyTWLC oBmjsWdBBtCN1OvEj5/WAZdG6AG6FmazcEiQmkNPc2JO9l6eU/ZeX7+HJJXakfqPng8w JvJ8Cner1TYHinpJ7X3EPrqAPLIVAQWLTg6X2FbWTnvrcz41yUxGM1id+DAxGMAJURZw QiXknxxLJuW6gKOvfdMgHi2pVFvtFhNE/TpT8yM9LmxRYWa2O1O3yiQnMsurd5kjUMyG SWTXtuQhm2TphnRfSpw3e8/rbtqsfb2fW6L9KLxsnS+8RIvkUYosYCZ03D6wNDjix5S2 IQCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vrCRdPvqXLwfcbFZbk4xQpB3sIke8Dnzk1UweHKnIBI=; b=mUJuVEWhZ2snWhKsTPbP7pQ26JSHLZgzWsmHxXxZ3JS+DjEGqL7mSfmaucccyUEnhf 9d0LB18pSpwzn2bDGvekOXbVLbZZmYchpLPAQjUmoMgxkogBAIlAx1Y8Ny1hJAkbZWzx uNJ9Y3aw4m1FgaQsJxRBe+pqqZF/1HJal3hI7xNVxBkRIqePUbd3jzSljp38ZFtn7H1V bT4flJ9BgLNJyQidA6nxU5oxLmZ6wMAGyz3kWxUtmyyrNBkmlAmWn13RxvbFTTLR0Lah Jw5yig36pBXgYMJX9yanyoIOIXLuxAG4Fk1Bf8x7S1enzotQ8WDeoqx8FYpk0StXCMKt hmBg== X-Gm-Message-State: AOAM531UEvaojNPlPKGD33KVgVvk1T/z6cyT/YUabNOzvBq05pd+TpNy yIzudty4uiA0YHxXKVC3D3E= X-Google-Smtp-Source: ABdhPJzC3t6Smaaz6DordybL+mPFu1KmPHHpUWPJwrtzJBCyU8yCSfpMYbtaMuwiMQkDPdu1dkN//A== X-Received: by 2002:a92:1a12:: with SMTP id a18mr27989630ila.168.1620759091205; Tue, 11 May 2021 11:51:31 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:30 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 12/28] dyndbg: allow deleting site info via control interface Date: Tue, 11 May 2021 12:50:41 -0600 Message-Id: <20210511185057.3815777-13-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=dRr3KBsH; spf=pass (imf26.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.169 as permitted sender) smtp.mailfrom=jimcromie@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D86F44080F78 X-Stat-Signature: wtpzyuefwp34njh3dujna69jmtsbj3y3 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf26; identity=mailfrom; envelope-from=""; helo=mail-il1-f169.google.com; client-ip=209.85.166.169 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759077-95553 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Allow users & subsystems to selectively delete callsite info for pr-debug callsites. Hopefully, this can lead to actual recovery of memory. DRM is a potential user which would drop the sites: - has distinct categories for logging, and can map them over to a format prefix, like: "drm:core:", "drm:kms:", etc. - are happy with group control of all the callsites in a class/cateory. individual control is still possible using queries including line numbers - don't need dynamic "module:function:line:" prefixes in log messages - don't care about loss of context in /proc/dynamic_debug/control before: init/initramfs.c:485 [initramfs]unpack_to_rootfs =_ "Detected %s compressed data\012" init/main.c:1337 [main]run_init_process =pm " %s\012" init/main.c:1335 [main]run_init_process =pm " with environment:\012" init/main.c:1334 [main]run_init_process =pm " %s\012" init/main.c:1332 [main]run_init_process =pm " with arguments:\012" init/main.c:1121 [main]initcall_blacklisted =pm "initcall %s blacklisted\012" init/main.c:1082 [main]initcall_blacklist =pm "blacklisting initcall %s\012" then: bash-5.0# echo file init/main.c +D > /proc/dynamic_debug/control after: init/initramfs.c:485 [initramfs]unpack_to_rootfs =_ "Detected %s compressed data\012" [main]:1337 =pmD " %s\012" [main]:1335 =pmD " with environment:\012" [main]:1334 =pmD " %s\012" [main]:1332 =pmD " with arguments:\012" [main]:1121 =pmD "initcall %s blacklisted\012" [main]:1082 =pmD "blacklisting initcall %s\012" Notes: If Drm adopted dyndbg, i915 + drm* would add ~1600 prdebugs, amdgpu + drm* would add ~3200 callsites, so the additional memory costs are substantial. In trade, drm and drivers would avoid lots of calls to drm_debug_enabled(). This patch should reduce the costs. Using this interface, drm could drop site info for all categories / prefixes controlled by bits in drm.debug, while preserving site info and individual selectivity for any uncategorized prdebugs, and for all other modules. Lastly, because lineno field was not moved into _ddebug_callsite, it can be used to modify a single[*] callsite even if drm has dropped all the callsite data: echo module $mod format ^$prefix line $line +p >control Dropping site info is a one-way, information losing operation, so minor misuse is possible. Worst case is maybe (depending upon previous settings) some loss of logging context/decorations. echo +D > /proc/dynamic_debug/control [*] amdgpu has some macros invoking clusters of pr_debugs; each use of them creates a cluster of pr-debugs with the same line number. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 1 + lib/dynamic_debug.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index d56c02ed0c45..bc4e778b755c 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -40,6 +40,7 @@ struct _ddebug { #define _DPRINTK_FLAGS_INCL_FUNCNAME (1<<2) #define _DPRINTK_FLAGS_INCL_LINENO (1<<3) #define _DPRINTK_FLAGS_INCL_TID (1<<4) +#define _DPRINTK_FLAGS_DELETE_SITE (1<<7) /* drop site info to save ram */ #define _DPRINTK_FLAGS_INCL_ANY \ (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME |\ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a4ddafdbd9a1..76315d20672a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -92,6 +92,7 @@ static struct { unsigned flag:8; char opt_char; } opt_array[] = { { _DPRINTK_FLAGS_INCL_LINENO, 'l' }, { _DPRINTK_FLAGS_INCL_TID, 't' }, { _DPRINTK_FLAGS_NONE, '_' }, + { _DPRINTK_FLAGS_DELETE_SITE, 'D' }, }; struct flagsbuf { char buf[ARRAY_SIZE(opt_array)+1]; }; @@ -201,6 +202,14 @@ static void ddebug_alter_site(struct _ddebug *dp, } else if (modifiers->flags & _DPRINTK_FLAGS_PRINT) static_branch_enable(&dp->key.dd_key_true); #endif + /* delete site info for this callsite */ + if (modifiers->flags & _DPRINTK_FLAGS_DELETE_SITE) { + if (dp->site) { + vpr_info("dropping site info %s.%s.%d\n", dp->site->filename, + dp->site->function, dp->lineno); + dp->site = NULL; + } + } } /* From patchwork Tue May 11 18:50:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251855 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 99F36C433ED for ; Tue, 11 May 2021 18:51:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1C9FD61185 for ; Tue, 11 May 2021 18:51:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C9FD61185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6AF686B0085; Tue, 11 May 2021 14:51:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 685126B0087; Tue, 11 May 2021 14:51:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 414F66B0088; Tue, 11 May 2021 14:51:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0022.hostedemail.com [216.40.44.22]) by kanga.kvack.org (Postfix) with ESMTP id 20EA66B0085 for ; Tue, 11 May 2021 14:51:35 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D8C758249980 for ; Tue, 11 May 2021 18:51:34 +0000 (UTC) X-FDA: 78129843708.40.73F5C21 Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) by imf27.hostedemail.com (Postfix) with ESMTP id 6394F8019389 for ; Tue, 11 May 2021 18:51:33 +0000 (UTC) Received: by mail-il1-f172.google.com with SMTP id r5so18069325ilb.2 for ; Tue, 11 May 2021 11:51:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aWjz67jruSBa3AfnJK6T0K+rhp52me264VjeXl1/Rrw=; b=tcmZbpv4N7BmdgE/VhMdKYX5VajzQkXZ9HM9JhHaPQegrpCIW6+E8YvZtCfgkdj/1q uCKZCSoPJb84nkdfmWQpXyFsga/opJNb0sc0Lm1lPgBD83G7Ab964HZMQxHXmk9g3NBY Csth1IFzOhyIUsjpkJ6BBIriMaY8S5e4meZjdOoOfCbIKa9/OTa5NImaId8UNpVh1GRq YTjVInNQ7c7romCCF2Pj0ujgveX/KhTfhzZJ8OdPY6ECAo+4PbszxPqjbhlPMQRDAYR8 8C1aQWMs7JJ2qqOmzjb7HRUXiBwTTtzviJ99li2XUuJ7wSQrTgSVTRiaT0hxXNF8zMsD 7Fzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aWjz67jruSBa3AfnJK6T0K+rhp52me264VjeXl1/Rrw=; b=IQ7czJXtrFRWDrdkfqpMv0UbEA0J6PHvND/wwommVdroKvMgbLhuiPZ+ZhiJYgCI+P ISXdOWSKlFggTGvxpJRA8uZi2FJxkhjmDY1Eoh4ZXfh5KIlYv5HGqnzi3EW+4vbHBd+C Aez3kpNXmp0qbTQrsg/tUi2Mpn6bdyhKgmLc5rVLVq0KdzDdf62MsYJV4j/iiZluUf0F aT6GCaDVEgGQKVBE+5lVDiKfWkYfGBKxwo5+UTubIL540YVg6fbZPwrqLNHZVl5UPrNN BRdfpbDSyiMeVb2b+O4IRdqiafadY4x55ASybxTz/YdnIS8w9nGtD1kagSd8hcIAlV0U g9lQ== X-Gm-Message-State: AOAM532drpHWRNu4Bk/FAKGQxI6VZKQUDXV9T8ihs9dNJiCSAmeFPjrr 8+lKgFDIIrDjSrxCIzxnRuQ= X-Google-Smtp-Source: ABdhPJyHyeXZ+uUGCw0gMpIlqjjffT+dvi62Suw1jrSBFF3VZEqbivUlNjZAqyX6XfY4bgsVNK6m/g== X-Received: by 2002:a92:c7a9:: with SMTP id f9mr26182241ilk.255.1620759093805; Tue, 11 May 2021 11:51:33 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:33 -0700 (PDT) From: Jim Cromie To: Jason Baron , Jessica Yu , "GitAuthor: Jim Cromie" , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, kernel test robot Subject: [RFC PATCH v5 13/28] dyndbg+module: expose ddebug_sites to modules Date: Tue, 11 May 2021 12:50:42 -0600 Message-Id: <20210511185057.3815777-14-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 6394F8019389 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=tcmZbpv4; spf=pass (imf27.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.172 as permitted sender) smtp.mailfrom=jimcromie@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Stat-Signature: eha8jgwhmrziiij1y8tuyc1h96m8ijnn Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf27; identity=mailfrom; envelope-from=""; helo=mail-il1-f172.google.com; client-ip=209.85.166.172 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759093-352913 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Up until now, the "__dyndbg_sites" section was kinda dangling. Unlike the "__dyndbg" section, it was not explicitly loaded by module.c:load_info(); but it came along quietly, perhaps because of the per .site initialization (by DEFINE_DYNAMIC_DEBUG_METADATA) across the section boundary, or maybe because x86 is more permissive. ISTM we need to treat "__dyndbg_sites" section just like "__dyndbg", on basic principles. (And maybe do this with commit that splits the sections, if robot tests indicate problems between). The changes to load_info propagated out to ddebug_add_module's prototype, which needs to manage the 2nd section like the 1st. RFC: Maybe the 2 sections/arrays should be a single item/tuple, but I didn't see any real benefit to adding something; recapitulating the previous pattern was straightforward. -v5 fix !CONFIG_DYNAMIC_DEBUG fn-stub Reported-by: kernel test robot Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 8 ++++---- kernel/module-internal.h | 1 + kernel/module.c | 9 ++++++--- lib/dynamic_debug.c | 20 ++++++++++++-------- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index bc4e778b755c..868e0769b72d 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -66,8 +66,8 @@ struct _ddebug { /* exported for module authors to exercise >control */ int dynamic_debug_exec_queries(const char *query, const char *modname); -int ddebug_add_module(struct _ddebug *tab, unsigned int n, - const char *modname); +int ddebug_add_module(struct _ddebug *tab, struct _ddebug_site *sites, + unsigned int numdbgs, const char *modname); extern int ddebug_remove_module(const char *mod_name); extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); @@ -199,8 +199,8 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #include #include -static inline int ddebug_add_module(struct _ddebug *tab, unsigned int n, - const char *modname) +static inline int ddebug_add_module(struct _ddebug *tab, struct _ddebug_site *sites, + unsigned int numdbgs, const char *modname) { return 0; } diff --git a/kernel/module-internal.h b/kernel/module-internal.h index 33783abc377b..fb61eb2f8032 100644 --- a/kernel/module-internal.h +++ b/kernel/module-internal.h @@ -18,6 +18,7 @@ struct load_info { char *secstrings, *strtab; unsigned long symoffs, stroffs, init_typeoffs, core_typeoffs; struct _ddebug *debug; + struct _ddebug_site *sites; unsigned int num_debug; bool sig_ok; #ifdef CONFIG_KALLSYMS diff --git a/kernel/module.c b/kernel/module.c index 30479355ab85..792903230acd 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2780,11 +2780,12 @@ static void add_kallsyms(struct module *mod, const struct load_info *info) } #endif /* CONFIG_KALLSYMS */ -static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsigned int num) +static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, + struct _ddebug_site *sites, unsigned int num) { if (!debug) return; - ddebug_add_module(debug, num, mod->name); + ddebug_add_module(debug, sites, num, mod->name); } static void dynamic_debug_remove(struct module *mod, struct _ddebug *debug) @@ -3333,6 +3334,8 @@ static int find_module_sections(struct module *mod, struct load_info *info) info->debug = section_objs(info, "__dyndbg", sizeof(*info->debug), &info->num_debug); + info->sites = section_objs(info, "__dyndbg_sites", + sizeof(*info->sites), &info->num_debug); return 0; } @@ -4004,7 +4007,7 @@ static int load_module(struct load_info *info, const char __user *uargs, goto free_arch_cleanup; } - dynamic_debug_setup(mod, info->debug, info->num_debug); + dynamic_debug_setup(mod, info->debug, info->sites, info->num_debug); /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */ ftrace_module_init(mod); diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 76315d20672a..1441b31915e7 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -49,6 +49,7 @@ struct ddebug_table { const char *mod_name; unsigned int num_ddebugs; struct _ddebug *ddebugs; + struct _ddebug_site *sites; }; struct ddebug_query { @@ -1008,14 +1009,14 @@ static const struct proc_ops proc_fops = { * Allocate a new ddebug_table for the given module * and add it to the global list. */ -int ddebug_add_module(struct _ddebug *tab, unsigned int n, - const char *name) +int ddebug_add_module(struct _ddebug *tab, struct _ddebug_site *sites, + unsigned int numdbgs, const char *modname) { struct ddebug_table *dt; dt = kzalloc(sizeof(*dt), GFP_KERNEL); if (dt == NULL) { - pr_err("error adding module: %s\n", name); + pr_err("error adding module: %s\n", modname); return -ENOMEM; } /* @@ -1024,15 +1025,16 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, * member of struct module, which lives at least as long as * this struct ddebug_table. */ - dt->mod_name = name; - dt->num_ddebugs = n; + dt->mod_name = modname; + dt->num_ddebugs = numdbgs; dt->ddebugs = tab; + dt->sites = sites; mutex_lock(&ddebug_lock); list_add(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); - v2pr_info("%3u debug prints in module %s\n", n, dt->mod_name); + v2pr_info("%3u debug prints in module %s\n", numdbgs, modname); return 0; } @@ -1172,7 +1174,9 @@ static int __init dynamic_debug_init(void) if (strcmp(modname, site->modname)) { modct++; - ret = ddebug_add_module(iter_mod_start, site_ct, modname); + + ret = ddebug_add_module(iter_mod_start, site_mod_start, + site_ct, modname); if (ret) goto out_err; site_ct = 0; @@ -1182,7 +1186,7 @@ static int __init dynamic_debug_init(void) } site_ct++; } - ret = ddebug_add_module(iter_mod_start, site_ct, modname); + ret = ddebug_add_module(iter_mod_start, site_mod_start, site_ct, modname); if (ret) goto out_err; From patchwork Tue May 11 18:50:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251857 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 625A2C43460 for ; Tue, 11 May 2021 18:51:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0FCFE611BD for ; Tue, 11 May 2021 18:51:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0FCFE611BD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 21A5D6B0087; Tue, 11 May 2021 14:51:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1542A6B0088; Tue, 11 May 2021 14:51:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F102E6B0089; Tue, 11 May 2021 14:51:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id D52D56B0087 for ; Tue, 11 May 2021 14:51:35 -0400 (EDT) Received: from smtpin32.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A0194181AEF3F for ; Tue, 11 May 2021 18:51:35 +0000 (UTC) X-FDA: 78129843750.32.A8A1F08 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) by imf01.hostedemail.com (Postfix) with ESMTP id 2B4035001522 for ; Tue, 11 May 2021 18:51:32 +0000 (UTC) Received: by mail-io1-f42.google.com with SMTP id a11so19173450ioo.0 for ; Tue, 11 May 2021 11:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=be8g977AZ5bDeKF0B08Lx0EuPmyTmMUIPQ9/ceBeosg=; b=Gza6ZZPlOYH97az7teoGtiOBvrypZ4gz6Tq+qYV+S8QHwAQaCNulTaH2rSWVCpxiWP qtSkgTVNXomxSj0Y+DmNarQrJb7SaAitApc+zebdIuEl1BQsDE+76uSoFjKRYRT+M9fx hM1G8Z+UGi7f7W5+4ZW/w3ghxFXMxL2sH6jW+zO9lHXUzorUbaJMuHRgubxpWYKSX9HM FQge0xqiMm/vma34WvNR5JNXrFdem0pvvc4GiAW6p4xd4b6A0eTt0OhQ+c1GF3/AxEcJ RO1ntb1Osnr1f2Ge1F91Dl01j2YPFowmGLQqj2GrKwekrldxmzBn68GM8MlxKtBzAzsE Tsxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=be8g977AZ5bDeKF0B08Lx0EuPmyTmMUIPQ9/ceBeosg=; b=AZhx/jFLsKMsu9yTZ1K/MfUaBEhysXBXalH2QxTq3GU1cdRG+zUBNQoKG3rlyjnQiI ebFb64OWEHvAgbk5YggX2nZJbIb/ncs+KsVWfpGeByIhMjZ7MUwIVd9DMkSFZE8wRAdT I5nEj5Hn4C9pdQRx4g3jMdUqCcy3ttItLERtyn2Kuk/Z30t6iaPz2QanjknRoYwuXzoC WL7KGoiH/cNOJD85Wyfg5iwpJcF/0EAEcLzK6/vYcBKqTlzudhXBk7WYrqN6AOegqg+G b9OBNOmJDt3vm9f+j/Xdfah59TgE+nCrq6Vy8ma2kkycv00zqt4EP/0IcVDcXtTizca/ GseQ== X-Gm-Message-State: AOAM531kOcJ47qve89a15lHsJZLF3LVURPBjIPhbvyIg3vjEuaa/T0z/ 4r3g5ftics3QJh+THbk35NM= X-Google-Smtp-Source: ABdhPJwJEnJHsn2AEinRleOhYeJoPFdY8E7nfKDfQwU6fZnspnBCl/X3CxKfV0FIu2/z9S8AG6OguA== X-Received: by 2002:a05:6638:3c8:: with SMTP id r8mr27928630jaq.112.1620759094788; Tue, 11 May 2021 11:51:34 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:34 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 14/28] dyndbg: add ddebug_site(_get|_put) abstraction Date: Tue, 11 May 2021 12:50:43 -0600 Message-Id: <20210511185057.3815777-15-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2B4035001522 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=Gza6ZZPl; spf=pass (imf01.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.42 as permitted sender) smtp.mailfrom=jimcromie@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Stat-Signature: sm16gysjc3ruo88cp146ibhzmh9knz3r Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=mail-io1-f42.google.com; client-ip=209.85.166.42 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759092-606123 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Replace direct ->site refs with _get(),_put() internal API. Right now, _get() just returns ->site and _put() does nothing. Later we can replace this implementation with one using ->_index to fetch site data then forget or keep it selectively. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 1441b31915e7..90bea97c0da1 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -144,6 +144,14 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg) query->first_lineno, query->last_lineno); } +static struct _ddebug_site *ddebug_site_get(struct _ddebug *dp) +{ + return dp->site; /* passthru abstraction */ +} +static inline void ddebug_site_put(struct _ddebug *dp) +{ +} + static int ddebug_match_site(const struct ddebug_query *query, const struct _ddebug *dp, const struct _ddebug_site *dc) @@ -239,16 +247,18 @@ static int ddebug_change(const struct ddebug_query *query, for (i = 0; i < dt->num_ddebugs; i++) { struct _ddebug *dp = &dt->ddebugs[i]; - struct _ddebug_site *dc = dp->site; + struct _ddebug_site *dc; + + dc = ddebug_site_get(dp); if (!ddebug_match_site(query, dp, dc)) - continue; + goto skipsite; nfound++; newflags = (dp->flags & modifiers->mask) | modifiers->flags; if (newflags == dp->flags) - continue; + goto skipsite; ddebug_alter_site(dp, modifiers); @@ -264,6 +274,9 @@ static int ddebug_change(const struct ddebug_query *query, dt->mod_name, dp->lineno, ddebug_describe_flags(dp->flags, &fbuf), dp->format); + +skipsite: + ddebug_site_put(dp); } } mutex_unlock(&ddebug_lock); @@ -633,11 +646,11 @@ static int remaining(int wrote) return 0; } -static char *__dynamic_emit_prefix(const struct _ddebug *dp, char *buf) +static char *__dynamic_emit_prefix(struct _ddebug *dp, char *buf) { int pos_after_tid; int pos = 0; - const struct _ddebug_site *desc = dp->site; + const struct _ddebug_site *desc; if (dp->flags & _DPRINTK_FLAGS_INCL_TID) { if (in_interrupt()) @@ -648,6 +661,7 @@ static char *__dynamic_emit_prefix(const struct _ddebug *dp, char *buf) } pos_after_tid = pos; + desc = ddebug_site_get(dp); if (desc) { if (dp->flags & _DPRINTK_FLAGS_INCL_MODNAME) pos += snprintf(buf + pos, remaining(pos), "%s:", @@ -665,6 +679,8 @@ static char *__dynamic_emit_prefix(const struct _ddebug *dp, char *buf) if (pos >= PREFIX_SIZE) buf[PREFIX_SIZE - 1] = '\0'; + ddebug_site_put(dp); + return buf; } @@ -947,7 +963,8 @@ static int ddebug_proc_show(struct seq_file *m, void *p) return 0; } - dc = dp->site; + dc = ddebug_site_get(dp); + if (dc) { seq_printf(m, "%s:%u [%s]%s =%s \"", trim_prefix(dc->filename), dp->lineno, @@ -963,6 +980,8 @@ static int ddebug_proc_show(struct seq_file *m, void *p) seq_puts(m, "\"\n"); } + ddebug_site_put(dp); + return 0; } From patchwork Tue May 11 18:50:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251859 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 5804BC433B4 for ; Tue, 11 May 2021 18:51:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DECA3611BD for ; Tue, 11 May 2021 18:51:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DECA3611BD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 60FE36B0088; Tue, 11 May 2021 14:51:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E88B6B0089; Tue, 11 May 2021 14:51:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43A5E6B008A; Tue, 11 May 2021 14:51:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id 268146B0088 for ; Tue, 11 May 2021 14:51:38 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id EA1E9AF74 for ; Tue, 11 May 2021 18:51:36 +0000 (UTC) X-FDA: 78129843792.03.E4119AC Received: from mail-il1-f170.google.com (mail-il1-f170.google.com [209.85.166.170]) by imf20.hostedemail.com (Postfix) with ESMTP id 258113C5 for ; Tue, 11 May 2021 18:51:36 +0000 (UTC) Received: by mail-il1-f170.google.com with SMTP id w7so1343738ilg.13 for ; Tue, 11 May 2021 11:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0akxANKNkbeQrtz/Nl9c6Kx9Ebh3LtjGjFZCG1KZ/Qw=; b=VX6dmSWJmZjkV1Rhp9aEogYuhqVXAsUR9aVeobbq22ovtj7fXTCQyxSllKzJT4mH96 p0fsLzFvvYUYxOzUGRB/VztsCI8y4/GRYK915XL2CQ7KdgfP1SD2PSMu0tWtYDlFg7zk I4gjTSFA/YsER9BONCczRiOpQR87c7/arpJftFNKJZqucVpd3fmPrrEjjjNgdS1MU3BF RUMtD0gfTVCIah3Ohue09qagSO7APCFWHSm80sgjQs/C15DvW78C4+RZ+XvMUAqDkteO qLXF0vYIESojXqkqRJbb+bPfcVKq9REgizFZ3uCTVaQWsaxycsVTHMQYUWgDLpszTHEa GzAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0akxANKNkbeQrtz/Nl9c6Kx9Ebh3LtjGjFZCG1KZ/Qw=; b=QsootjTW3zmAExIfZGRvdLu3bhjnYOTrCfz1iFdNUvZtoMkh2GFzr3lgo3V+8LaFrg McqKF7trUI3SPhdPMarSptN4gLPTy6h5hdquE2eB3gcDivAWsZeZbHN9ZojiBjtHabOI qYLc54Ppea/HqqeMLPW5Uaz0nVagsMXQdhAuyO/hHCwz1Q6a8ko3pd0SscCm7Bh5u8Z1 lm8PVlrDcJ1Uupi3AowbXPsvvFTvMDwF86hwMl93ZDeGFoJn4FvG4G36oEYlDPQQvkHK ySGyrrdXNuGfBXFVU8ZhdbgsAR9ztWQB/axdQhBowhJUeOyu9lt/o8HTXJRJmBpHgu40 3gdQ== X-Gm-Message-State: AOAM531IlI9lOQZuG8OPiAW/eLzvqJuEM2ICdps8jS+fLZrGp99dmlQA PiSEuf3k2Fi16w4fVL3C6Sg= X-Google-Smtp-Source: ABdhPJzEqx3UMwEioPfdqtJkFucKMAHNwHuJDWooC/COz4fEzHQN50FHXHQCY3bxq0VaORRmj0Fa6Q== X-Received: by 2002:a92:650d:: with SMTP id z13mr13363441ilb.193.1620759095707; Tue, 11 May 2021 11:51:35 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:35 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 15/28] dyndbg: ddebug_add_module avoid adding empty modules Date: Tue, 11 May 2021 12:50:44 -0600 Message-Id: <20210511185057.3815777-16-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=VX6dmSWJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.170 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 258113C5 X-Stat-Signature: iu14mas7ogjhw17ruqdbb9x6djdh67x6 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf20; identity=mailfrom; envelope-from=""; helo=mail-il1-f170.google.com; client-ip=209.85.166.170 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759096-320784 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Don't create ddebug_table's for modules with 0 callsites. This saves memory, and avoids creating ddebug_tables with questionable contents, which are then iterated over for 'cat control'. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 90bea97c0da1..77c5135879c2 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1033,6 +1033,12 @@ int ddebug_add_module(struct _ddebug *tab, struct _ddebug_site *sites, { struct ddebug_table *dt; + v3pr_info("add-module: %s.%d sites\n", modname, numdbgs); + if (!numdbgs) { + v3pr_info(" skip %s\n", modname); + return 0; + } + dt = kzalloc(sizeof(*dt), GFP_KERNEL); if (dt == NULL) { pr_err("error adding module: %s\n", modname); From patchwork Tue May 11 18:50:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251861 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 1C9D2C433B4 for ; Tue, 11 May 2021 18:51:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A6AD261185 for ; Tue, 11 May 2021 18:51:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6AD261185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CEF736B0089; Tue, 11 May 2021 14:51:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CCB386B008A; Tue, 11 May 2021 14:51:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B3CFA8D0001; Tue, 11 May 2021 14:51:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id 983566B0089 for ; Tue, 11 May 2021 14:51:38 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DF8C28249980 for ; Tue, 11 May 2021 18:51:37 +0000 (UTC) X-FDA: 78129843834.25.E6805A6 Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) by imf25.hostedemail.com (Postfix) with ESMTP id 47CC3600249C for ; Tue, 11 May 2021 18:51:29 +0000 (UTC) Received: by mail-io1-f54.google.com with SMTP id n40so3409704ioz.4 for ; Tue, 11 May 2021 11:51:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rH6B1Y8q3MjL1HohSGCYSWCX5UPnZylow4i2opQMHbM=; b=NFlJHIjk/PDNRHFQangXdJx77gLySvGEbGxTDWq2llBhEQBjAgXbb95fn8TFFfLWUo 6U3Uaqb9RB/7q0/uHQ65B3loUBI6KKaOEkbEUMqJAZUiXMZAL/RKtMxUgda32/YUwt9L Z/BqBbbBBxzlcpK+7pOgcs9lNwswGZZnonlSCqdjAfgw6vwxDrlIwls/qsx3p4Pl0sqr 8psBZDphKP6BGGVFyTcvF2ReDgNeLCaN3v9vUkFAzw5zdLW0y1LsZxxGv0VQ5kmlzng+ omP5/ubfaS8yrZ293O3EZK7lVQYwJYnYtE+3hqPl0Su5n/Oq2voBrGUMP1QfuxgBqq21 nPjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rH6B1Y8q3MjL1HohSGCYSWCX5UPnZylow4i2opQMHbM=; b=gCrGtJ60HLjk/sEGyzPwyHOVW1H0WR7FQqeoMxEAGmN8Eap+stk+9oFQjrAX4kAknK 5oF4X7IyohNBNq0OgUVw9nSKrSOSFIZiZZ5KVXsDXI3f7PKmoAi5GtG+hagHIiO8B9fN r4GzIF9tDSIhbSH8g0li4Dd7Z0icSd4Na29buc+LgxLOpTA/e7jjlbZNIjcVpY6bERFp Fz5QL3BblHeRg99zM1W0ymtiYXrKs05I1EMazD94zsPoNxh6pgfaNnr2np7bmgJP7hoI ZY6VimshqHUJHxbE0yXQmps9tl2uHKl2CusPbQNJwsWOQbHHrccIrmhBPH6CQv6bdEGF 72ZQ== X-Gm-Message-State: AOAM530/9BwPeob+e8K7IyV90eKNlgBYpDY0QIXIY1HPB/q1hNQCVQ9z 9QIKuEl4fjaJ0ytZFoH2ENk6A/B63elxKQ== X-Google-Smtp-Source: ABdhPJwvWQ+pbKNdxpmYzkb2pNO0aP/DoUsS/MuIU6IoqmOHDEVTYnK6Jy/D9YAAHACdcEFCXJ0s6A== X-Received: by 2002:a05:6602:24d4:: with SMTP id h20mr23481287ioe.4.1620759096947; Tue, 11 May 2021 11:51:36 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:36 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 16/28] dyndbg: add _index to struct _ddebug Date: Tue, 11 May 2021 12:50:45 -0600 Message-Id: <20210511185057.3815777-17-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=NFlJHIjk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.54 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Stat-Signature: 4n1yikasz75a9gkp8gb65wrxib3f433r X-Rspamd-Queue-Id: 47CC3600249C X-Rspamd-Server: rspam02 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf25; identity=mailfrom; envelope-from=""; helo=mail-io1-f54.google.com; client-ip=209.85.166.54 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759089-491619 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: We currently use dp->site to map: &__dyndbg[N] -> &__dyndbg_sites[N]. We want to drop site; new _ddebug._index provides the N. This just initializes that index. ddebug_add_module()'s new job is to initialize _index. In order to handle builtin modules (sections contain catenated blocks of modules' callsites) it gets a new base arg to monotonically increment _index over multiple modules. Since ddebug_add_module() is used indirectly by module.c, the new arg is hidden in __ddebug_add_module(), and defaults to 0 in the wrapper. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 2 ++ lib/dynamic_debug.c | 25 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 868e0769b72d..a15e417cbba8 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -29,6 +29,7 @@ struct _ddebug { /* format is always needed, lineno shares word with flags */ const char *format; const unsigned lineno:18; + unsigned _index:14; /* * The flags field controls the behaviour at the callsite. * The bits here are changed dynamically when the user @@ -52,6 +53,7 @@ struct _ddebug { #define _DPRINTK_FLAGS_DEFAULT 0 #endif unsigned int flags:8; + #ifdef CONFIG_JUMP_LABEL union { struct static_key_true dd_key_true; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 77c5135879c2..c5927b6c1c0c 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1028,10 +1028,12 @@ static const struct proc_ops proc_fops = { * Allocate a new ddebug_table for the given module * and add it to the global list. */ -int ddebug_add_module(struct _ddebug *tab, struct _ddebug_site *sites, - unsigned int numdbgs, const char *modname) +static int __ddebug_add_module(struct _ddebug *tab, struct _ddebug_site *sites, + unsigned int numdbgs, unsigned int base, + const char *modname) { struct ddebug_table *dt; + int i; v3pr_info("add-module: %s.%d sites\n", modname, numdbgs); if (!numdbgs) { @@ -1055,6 +1057,12 @@ int ddebug_add_module(struct _ddebug *tab, struct _ddebug_site *sites, dt->ddebugs = tab; dt->sites = sites; + for (i = 0; i < numdbgs; i++, base++) { + tab[i]._index = base; + v3pr_info(" %d %d %s.%s.%d\n", i, base, modname, + tab[i].site->function, tab[i].lineno); + } + mutex_lock(&ddebug_lock); list_add(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); @@ -1063,6 +1071,12 @@ int ddebug_add_module(struct _ddebug *tab, struct _ddebug_site *sites, return 0; } +int ddebug_add_module(struct _ddebug *tab, struct _ddebug_site *sites, + unsigned int numdbgs, const char *modname) +{ + return __ddebug_add_module(tab, sites, numdbgs, 0, modname); +} + /* helper for ddebug_dyndbg_(boot|module)_param_cb */ static int ddebug_dyndbg_param_cb(char *param, char *val, const char *modname, int on_err) @@ -1177,6 +1191,7 @@ static int __init dynamic_debug_init(void) char *cmdline; int ret = 0; int site_ct = 0, entries = 0, modct = 0; + int mod_index = 0; if (&__start___dyndbg == &__stop___dyndbg) { if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { @@ -1200,8 +1215,8 @@ static int __init dynamic_debug_init(void) if (strcmp(modname, site->modname)) { modct++; - ret = ddebug_add_module(iter_mod_start, site_mod_start, - site_ct, modname); + ret = __ddebug_add_module(iter_mod_start, site_mod_start, + site_ct, mod_index, modname); if (ret) goto out_err; site_ct = 0; @@ -1211,7 +1226,7 @@ static int __init dynamic_debug_init(void) } site_ct++; } - ret = ddebug_add_module(iter_mod_start, site_mod_start, site_ct, modname); + ret = __ddebug_add_module(iter_mod_start, site_mod_start, site_ct, mod_index, modname); if (ret) goto out_err; From patchwork Tue May 11 18:50:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251863 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 248A5C433B4 for ; Tue, 11 May 2021 18:51:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B0AE1611BD for ; Tue, 11 May 2021 18:51:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0AE1611BD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3F4006B008C; Tue, 11 May 2021 14:51:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28F4A6B0092; Tue, 11 May 2021 14:51:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9B418D0001; Tue, 11 May 2021 14:51:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0066.hostedemail.com [216.40.44.66]) by kanga.kvack.org (Postfix) with ESMTP id BCC3A6B008C for ; Tue, 11 May 2021 14:51:46 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 799CE1802DE17 for ; Tue, 11 May 2021 18:51:46 +0000 (UTC) X-FDA: 78129844212.22.5D2A9A7 Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) by imf20.hostedemail.com (Postfix) with ESMTP id C9E33ED for ; Tue, 11 May 2021 18:51:45 +0000 (UTC) Received: by mail-il1-f169.google.com with SMTP id j20so18028699ilo.10 for ; Tue, 11 May 2021 11:51:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a/h54JdNC5kR17fX7/LoX7g8+9V1SkM6LPGM//jz9YE=; b=TyuPG2wOFQrgKxI20nIja2mzk8NJAyGwIiLGj/NpdzrU1nuGJ3oPGW2TGiZg9bh6wd 30l/Phnddorg+Dvatg6e2gDVLUG7R3rAPN2Tgd3NmEqqFan8p6PHC/BHRVy8iRfaJKO/ amPeFT9M8GsyJElzvFaLAn6XDBv4c2LfW0nsjuUlmr8W6BpEzw+zMNtu2oMoNGHvcG8n gogAnm+letvJoMK/VTjaueLYu4SHHfVbY1uWf04y/zmGK7thYghUd94dqrU5FliesezB 8v5dWnyTDFWI0iz9wFXKfwg5Mi5uV4qoD9KMqGpRrSNSx29CnxRTbSnLd/H57hp6QPlO bPRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a/h54JdNC5kR17fX7/LoX7g8+9V1SkM6LPGM//jz9YE=; b=EUvtm/Hksn+nHePlDGCnPF3RfsAOcFZLOi2C2eQBZ5Qgpne6W79jcXxz1dsgRWR2CD xfA6ZkBsoTb9vYOeU+yj8khXfVDHlXPEN5mjItStLTvkvKkTKPhgggcwRmnuqx3CFR4l tSMC/ZAemvYqmNEnNxPF5NrmWnqSAg7yAFU/1/MHE03fmgsV+MIeJuE9H19sCoktF+xW mexK04U0mnamtFo6lMTg9tmPxI+/seTZZPH5FxZu54MtpRu8j0K09/USQw+lvFgO1U0T tOCCvfzAj93DaUXZBFFX/Np4UuFkoZ6aQ67FhCXvwKHKCOzG4LoUdUnrA6pI428dIPUP KM2g== X-Gm-Message-State: AOAM532O+CXEMQbw4NVF55EuDEV6yEMqznUTPgReWMIWRMZ7f5Nj5JR3 JlWhs+O+De6Q4SFvC9fY1Fs= X-Google-Smtp-Source: ABdhPJzcb33bvz5DI0nPKr87rXTBl99c1OgYhzBNlqj59Pxj7WEvcQRq6DDiruZk26m5IctEX86qCA== X-Received: by 2002:a05:6e02:1b85:: with SMTP id h5mr186059ili.303.1620759105380; Tue, 11 May 2021 11:51:45 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:44 -0700 (PDT) From: Jim Cromie To: Russell King , "David S. Miller" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Andy Lutomirski , Ard Biesheuvel , Kees Cook , Nick Desaulniers , Masahiro Yamada , Linus Walleij , Nathan Chancellor , Geert Uytterhoeven , Bill Wendling , Sami Tolvanen , Jim Cromie , Arvind Sankar , Joerg Roedel , Nick Terrell , Dave Young , Pingfan Liu , Atish Patra , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org, linux-efi@vger.kernel.org Cc: linux-mm@kvack.org, lkp@intel.com Subject: [RFC PATCH v5 17/28] dyndbg: prevent build bugs via -DNO_DYNAMIC_DEBUG_TABLE Date: Tue, 11 May 2021 12:50:46 -0600 Message-Id: <20210511185057.3815777-18-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=TyuPG2wO; spf=pass (imf20.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.169 as permitted sender) smtp.mailfrom=jimcromie@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: C9E33ED X-Stat-Signature: uh7uc57ws1tzbjkgsn4p6xkdbdxnz1c4 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf20; identity=mailfrom; envelope-from=""; helo=mail-il1-f169.google.com; client-ip=209.85.166.169 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759105-526031 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The next patch adds DEFINE_DYNAMIC_DEBUG_TABLE(), which broke several subtrees, including efi, vdso, and some of arch/*/boot/compressed, with various relocation errors, iirc. Avoid those problems by adding a define to suppress the "transparent" DEFINE_DYNAMIC_DEBUG_TABLE() invocation. I found the x86 problems myself, lkp@intel.com found arm & sparc problems, and may yet find others. Reported-by: # on [jimc:lkp-test/dyndbg-diet] recently Signed-off-by: Jim Cromie --- arch/arm/boot/compressed/Makefile | 2 ++ arch/sparc/vdso/Makefile | 2 ++ arch/x86/boot/compressed/Makefile | 1 + arch/x86/entry/vdso/Makefile | 3 +++ arch/x86/purgatory/Makefile | 1 + drivers/firmware/efi/libstub/Makefile | 3 ++- 6 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index fd94e27ba4fa..72f056a00ad4 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -82,6 +82,8 @@ compress-$(CONFIG_KERNEL_LZMA) = lzma compress-$(CONFIG_KERNEL_XZ) = xzkern compress-$(CONFIG_KERNEL_LZ4) = lz4 +KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE + libfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y) diff --git a/arch/sparc/vdso/Makefile b/arch/sparc/vdso/Makefile index c5e1545bc5cf..960ed0fb6804 100644 --- a/arch/sparc/vdso/Makefile +++ b/arch/sparc/vdso/Makefile @@ -30,6 +30,8 @@ obj-y += $(vdso_img_objs) targets += $(vdso_img_cfiles) targets += $(vdso_img_sodbg) $(vdso_img-y:%=vdso%.so) +KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE + CPPFLAGS_vdso.lds += -P -C VDSO_LDFLAGS_vdso.lds = -m elf64_sparc -soname linux-vdso.so.1 --no-undefined \ diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index e0bc3988c3fa..ada4eb960d95 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -31,6 +31,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \ KBUILD_CFLAGS := -m$(BITS) -O2 KBUILD_CFLAGS += -fno-strict-aliasing -fPIE KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING +KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE cflags-$(CONFIG_X86_32) := -march=i386 cflags-$(CONFIG_X86_64) := -mcmodel=small -mno-red-zone KBUILD_CFLAGS += $(cflags-y) diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index 05c4abc2fdfd..619878f2c427 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -29,6 +29,9 @@ vobjs32-y := vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o vobjs32-y += vdso32/vclock_gettime.o vobjs-$(CONFIG_X86_SGX) += vsgx.o +# avoid a x86_64_RELATIVE error +KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE + # files to link into kernel obj-y += vma.o extable.o KASAN_SANITIZE_vma.o := y diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile index 95ea17a9d20c..95ba7b18410f 100644 --- a/arch/x86/purgatory/Makefile +++ b/arch/x86/purgatory/Makefile @@ -35,6 +35,7 @@ PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss -g0 PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING PURGATORY_CFLAGS += -fno-stack-protector +PURGATORY_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That # in turn leaves some undefined symbols like __fentry__ in purgatory and not diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index c23466e05e60..def8febefbd3 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -13,7 +13,8 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ \ -Wno-pointer-sign \ $(call cc-disable-warning, address-of-packed-member) \ $(call cc-disable-warning, gnu) \ - -fno-asynchronous-unwind-tables + -fno-asynchronous-unwind-tables \ + -DNO_DYNAMIC_DEBUG_TABLE # arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly # disable the stackleak plugin From patchwork Tue May 11 18:50:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251865 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 E8636C433ED for ; Tue, 11 May 2021 18:51:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 738E2611AB for ; Tue, 11 May 2021 18:51:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 738E2611AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1F2186B0092; Tue, 11 May 2021 14:51:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A6468D0001; Tue, 11 May 2021 14:51:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8C0E6B0095; Tue, 11 May 2021 14:51:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0062.hostedemail.com [216.40.44.62]) by kanga.kvack.org (Postfix) with ESMTP id 975AE6B0092 for ; Tue, 11 May 2021 14:51:47 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5D3421807F304 for ; Tue, 11 May 2021 18:51:47 +0000 (UTC) X-FDA: 78129844254.03.52FD40F Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) by imf25.hostedemail.com (Postfix) with ESMTP id BD9D560006D5 for ; Tue, 11 May 2021 18:51:38 +0000 (UTC) Received: by mail-il1-f171.google.com with SMTP id c3so18078710ils.5 for ; Tue, 11 May 2021 11:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UmFJIyUaXJT257OL/LmtMVaV16lked49orHA6dOpiLw=; b=XRpp9WtoJag16JQlFNYd3Z4dVHrz7VWz/k2R1ZNTPMXy38+H1Rp1iygfzynxNNf6y9 RcI0C7QVxcOcfqWKLIM7fhQQN06WyIgsHiQwdt9tOIqFzEnPQh3pKC5JIU884IBR7wYu MtcoBTyEAHy9SFqqAMShxbCn7sdQjukd2qZAwGPO6Y/+Jj0zZ+MDO/JI2VPbCspmaXk4 n5iWvrKC7dXHZ8kqmUQfd/ejuxK2Vcfn6dlTLSmpI1AyZ5BXWFO6UlSzGj0XykiTLESx WLRZD/db8Ut9PcS/uXO9iBaNNnvhaxOzj/rDo0PnEJPcdXNXvAuhTrwHhollK+kr/Efv Ne1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UmFJIyUaXJT257OL/LmtMVaV16lked49orHA6dOpiLw=; b=ewMqoLrLI9ewRlHepxjgaiuWMujg+O9iiof+ZEnY33wyEaZOFTG488BlqTgdSxMZcC LaSE4cIH/2oLwlHf87J8zZUEBM3r/YOqzbIFN4AnvLRVSGXCKj8CJhH41K3zm7ewkNu5 +e86wrMPCSOrIyCOCHxEX19ojDviCdjQJn26qqKPwZXp/92hXIFaHAFf4dXnXPyW2p4c aXl2HzbMbefZDeGKwq+wdWohUNRIrDVBidpcFdchm5nVmTe9q1SwUnO8kpAfSrOBdrnz 8j64sX9CGo7GBSe4/+nI9VS2nYPyRwchtFEyPpV4YGAVNwmec4D211UbuBmsN+/LPs+2 nx6A== X-Gm-Message-State: AOAM533C5urEp15CwMwLlwP9xv0X58k4gNhHykbukO2GDxjM75lpvVTA C8ivfOpCHiePQplPN4mBIJA= X-Google-Smtp-Source: ABdhPJwAIWEWqcGtjz/0v8UZKqFhezkQ4HVghcAKCXOZQSajWCJQ1PG5ZoVf78BE73tfRClYkjyiwA== X-Received: by 2002:a05:6e02:e0a:: with SMTP id a10mr26327480ilk.271.1620759106391; Tue, 11 May 2021 11:51:46 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:46 -0700 (PDT) From: Jim Cromie To: Arnd Bergmann , Jason Baron , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 18/28] dyndbg: RFC - DEFINE_DYNAMIC_DEBUG_TABLE Date: Tue, 11 May 2021 12:50:47 -0600 Message-Id: <20210511185057.3815777-19-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=XRpp9Wto; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.171 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Stat-Signature: ho54cazxqgt6n958b9ncrw3u4qugca1b X-Rspamd-Queue-Id: BD9D560006D5 X-Rspamd-Server: rspam02 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf25; identity=mailfrom; envelope-from=""; helo=mail-il1-f171.google.com; client-ip=209.85.166.171 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759098-841898 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: DEFINE_DYNAMIC_DEBUG_TABLE is based on DEFINE_DYNAMIC_DEBUG_METADATA. Like its model, it creates/allocates a pair of structs: _ddebug & _ddebug_site. It inits them distinctively, so is_dyndbg_header_pair() macro can verify them. Its purpose is to reserve a single pair of header records in the front of the "__dyndbg" & "__dyndbg_sites" sections. This has several parts; - the pair of structs are placed into 2 .gnu.linkonce.dyndbg* sections corresponding to the 2 dyndbg* sections populated by _METADATA - vmlinux.lds.h places these 2 new sections into the dyndbg* sections, at the start___dyndbg*s. - the pair has "__used __weak" to qualm compiler concerns. explicit externs were problematic with initialization, static decls too. With this, the header record is now really __dyndbg[0]. Notes: DYNAMIC_DEBUG is a 'transparent' facility, in that pr_debug() users get extra features without additional api. Because of this, DEFINE_DYNAMIC_DEBUG_TABLE is invoked by dynamic_debug.h on behalf of all its (indirect) users, including printk.h. IOW this has wide effects; it results in multiple redundant declarations of header records, even single object files may get multiple copies. Placing these records into .gnu.linkonce. sections with "__used __weak " seems to resolve the redundancies. This may well be the cause of the need for HEAD~1. In vmlinux-lds.h, I added 2 more KEEPs to place the .gnu.linkonce.* headers at the front of their respective __dyndbg* sections. I moved the __dyndbg lines into a new macro, which maybe should be done as a separate commit, or in the earlier commit that touched it. RFC. The headers are really just struct _ddebug*s, they are initialized distinctively so that they're recogizable by code, using macro is_dyndbg_header_pair(dbg, dbgsite). DECLARE_DYNAMIC_DEBUG_TABLE() initializes the header record pairs with values which are "impossible" for pr_debug()s: - lineno == 0 - site == iter->site - modname == function not possible in proper linkage - modname == format not possible in normal linkage - filename = (void*) iter forced loopback Next: Get __dyndbg[0] from any *dp within __dyndbg[N]. Then with __dyndbg[0].site, we can get __dyndbg_sites[N]. This is a little slower than a direct pointer, but this is an unlikely debug path, so this 'up-N-over-down-N' access is ok. Eventually we can adapt the header (as a new struct/union) to keep its pointer to the __dyndbg_sites[] section/block, while allowing us to drop it from struct _ddebug, regaining memory parity with master. But for now, we keep .site, and will soon use it to validate the 'up-N-over-down-N' computation. For clarity, N is _ddebug._index. For both builtins & loadable modules, it is init'd to remember the fixed offset from the beginning of the section/block/memory-allocation (actual elf sections for *ko's, and a __start/__stop delineated part of .data for builtins). N/_index will be used solely to get to __debugs[0] and over to __debug_sites[N]. It is distinct from a module's numdbgs, which is used mainly when walking control, and is kept in struct _ddeug_table. Signed-off-by: Jim Cromie --- include/asm-generic/vmlinux.lds.h | 27 ++++++++++++------- include/linux/dynamic_debug.h | 45 +++++++++++++++++++++++++++++++ lib/dynamic_debug.c | 18 ++++++------- 3 files changed, 72 insertions(+), 18 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 4f2af9de2f03..189286405b40 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -335,6 +335,22 @@ KEEP(*(.dtb.init.rodata)) \ __dtb_end = .; +/* implement dynamic printk debug */ +#if defined(CONFIG_DYNAMIC_DEBUG) || defined(CONFIG_DYNAMIC_DEBUG_CORE) +#define DYNAMIC_DEBUG_DATA() \ + . = ALIGN(8); \ + __start___dyndbg_sites = .; \ + KEEP(*(.gnu.linkonce.dyndbg_site)) \ + KEEP(*(__dyndbg_sites)) \ + __stop___dyndbg_sites = .; \ + __start___dyndbg = .; \ + KEEP(*(.gnu.linkonce.dyndbg)) \ + KEEP(*(__dyndbg)) \ + __stop___dyndbg = .; +#else +#define DYNAMIC_DEBUG_DATA() +#endif + /* * .data section */ @@ -351,15 +367,8 @@ __end_once = .; \ STRUCT_ALIGN(); \ *(__tracepoints) \ - /* implement dynamic printk debug */ \ - . = ALIGN(8); \ - __start___dyndbg_sites = .; \ - KEEP(*(__dyndbg_sites)) \ - __stop___dyndbg_sites = .; \ - __start___dyndbg = .; \ - KEEP(*(__dyndbg)) \ - __stop___dyndbg = .; \ - LIKELY_PROFILE() \ + DYNAMIC_DEBUG_DATA() \ + LIKELY_PROFILE() \ BRANCH_PROFILE() \ TRACE_PRINTKS() \ BPF_RAW_TP() \ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index a15e417cbba8..06ae1d8d8c10 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -113,6 +113,43 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, _DPRINTK_KEY_INIT \ } +/* + * DEFINE_DYNAMIC_DEBUG_TABLE(): This is a special version of + * DEFINE_DYNAMIC_DEBUG_METADATA(). It creates a single pair of + * header records, which linker scripts place into __dyndbg[0] & + * __dyndbg_sites[0]. + * To allow a robust runtime test for is_dyndbg_header_pair(I,S), + * force-initialize S->filename to point back to I, an otherwize + * pathological condition. + */ +#define DEFINE_DYNAMIC_DEBUG_TABLE() \ + /* forward decl, allowing loopback pointer */ \ + __weak struct _ddebug __used __aligned(8) \ + __section(".gnu.linkonce.dyndbg") \ + _LINKONCE_dyndbg_header; \ + __weak struct _ddebug_site __used __aligned(8) \ + __section(".gnu.linkonce.dyndbg_site") \ + _LINKONCE_dyndbg_site_header = { \ + .modname = KBUILD_MODNAME, \ + .function = KBUILD_MODNAME, \ + /* forced pointer loopback, for distinction */ \ + .filename = (void *) &_LINKONCE_dyndbg_header \ + }; \ + __weak struct _ddebug __used __aligned(8) \ + __section(".gnu.linkonce.dyndbg") \ + _LINKONCE_dyndbg_header = { \ + .site = &_LINKONCE_dyndbg_site_header, \ + .format = KBUILD_MODNAME \ + } + +/* The header initializations as a distinguishing predicate */ +#define is_dyndbg_header_pair(iter, sitep) \ + (sitep == iter->site \ + && (!iter->lineno) \ + && (iter->format == sitep->modname) \ + && (sitep->modname == sitep->function) \ + && ((void *)sitep->filename == (void *)iter)) + #ifdef CONFIG_JUMP_LABEL #ifdef DEBUG @@ -243,4 +280,12 @@ static inline int dynamic_debug_exec_queries(const char *query, const char *modn #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ +#if ((defined(CONFIG_DYNAMIC_DEBUG) || \ + (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))) \ + && defined(KBUILD_MODNAME) && !defined(NO_DYNAMIC_DEBUG_TABLE)) + +/* transparently invoked, except when -DNO_DYNAMIC_DEBUG_TABLE */ +DEFINE_DYNAMIC_DEBUG_TABLE(); +#endif + #endif diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c5927b6c1c0c..9d9cb36f40a6 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1190,8 +1190,7 @@ static int __init dynamic_debug_init(void) const char *modname = NULL; char *cmdline; int ret = 0; - int site_ct = 0, entries = 0, modct = 0; - int mod_index = 0; + int i, site_ct = 0, modct = 0, mod_index = 0; if (&__start___dyndbg == &__stop___dyndbg) { if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { @@ -1207,10 +1206,9 @@ static int __init dynamic_debug_init(void) site = site_mod_start = __start___dyndbg_sites; modname = site->modname; - for (; iter < __stop___dyndbg; iter++, site++) { + for (i = 0; iter < __stop___dyndbg; iter++, site++, i++) { - BUG_ON(site != iter->site); - entries++; + WARN_ON(site != iter->site); if (strcmp(modname, site->modname)) { modct++; @@ -1219,10 +1217,12 @@ static int __init dynamic_debug_init(void) site_ct, mod_index, modname); if (ret) goto out_err; - site_ct = 0; + modname = site->modname; iter_mod_start = iter; site_mod_start = site; + mod_index += site_ct; + site_ct = 0; } site_ct++; } @@ -1232,9 +1232,9 @@ static int __init dynamic_debug_init(void) ddebug_init_success = 1; vpr_info("%d modules, %d entries and %d bytes in ddebug tables, %d bytes in __dyndbg section, %d bytes in __dyndbg_sites section\n", - modct, entries, (int)(modct * sizeof(struct ddebug_table)), - (int)(entries * sizeof(struct _ddebug)), - (int)(entries * sizeof(struct _ddebug_site))); + modct, i, (int)(modct * sizeof(struct ddebug_table)), + (int)(i * sizeof(struct _ddebug)), + (int)(i * sizeof(struct _ddebug_site))); /* apply ddebug_query boot param, dont unload tables on err */ if (ddebug_setup_string[0] != '\0') { From patchwork Tue May 11 18:50:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251867 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 F0CD2C43460 for ; Tue, 11 May 2021 18:51:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 80808611AB for ; Tue, 11 May 2021 18:51:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80808611AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3F0E16B0093; Tue, 11 May 2021 14:51:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 32C726B0095; Tue, 11 May 2021 14:51:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 044E96B0096; Tue, 11 May 2021 14:51:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0069.hostedemail.com [216.40.44.69]) by kanga.kvack.org (Postfix) with ESMTP id CA1AE6B0093 for ; Tue, 11 May 2021 14:51:48 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 786818249980 for ; Tue, 11 May 2021 18:51:48 +0000 (UTC) X-FDA: 78129844296.08.34050A0 Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) by imf08.hostedemail.com (Postfix) with ESMTP id EE65B80192E7 for ; Tue, 11 May 2021 18:51:20 +0000 (UTC) Received: by mail-il1-f172.google.com with SMTP id h6so18058058ila.7 for ; Tue, 11 May 2021 11:51:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1zPO68rECc+Worbr8mpoHDMicmfWQWDsecrogWsDsoQ=; b=lUOzvKR7OcFpY3RFzFgr4FfdY+ltDTeD+w+XTPlSXAD60lNeu0OutmmA3OapNwiIOs iOGGjwpez+HzgWZKjsLeHv/b7ne6PJXQGzWgJEryLJMkUuLeRJDhkHtKfnfQN54XHv+t iWg5/I8gU7sXudG/yQXuwEKlLk5+RqDXvgIL23dhr63JSghTd4PPQBtoSPw88Xe0mYb1 mdXZW4KQgIBgzqPRDkt46MQleqFIO14rbyTwJN77jc9KKKIJDnhc4K1S1qgtwqFK5cSI b5GCLFGyh7G5KxULcx9wtTmd/9ugmEXaDIcDl87WA3cq6Si7oKgmknwsAeKY6p7ODVW5 koRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1zPO68rECc+Worbr8mpoHDMicmfWQWDsecrogWsDsoQ=; b=kvQNaAZrpk7duwNN2Hb2Nxr+OJqrJrf9SFo0I+BKPYkd5SR5mbt8EtpBtgWdlf/1qK dseUDrlaJo2RxUbTtu3EUybrfE5nGRoT9kKENKZotAY+aOlyHvLI/41hmlWzwf7o2Cij OKpyHcFX/Jhn4uvZ+SrezeQrbUwZXjDUJarCsWZ+NRJVcbOzGmBaQHq6ZpO74+925uvc lixvfQacObxHs8fsc8xLG0HldQEgIAB2dn1ObEkLfGmqlDVImUSvuqtba3LEC/2FR9oJ CgXvvYjyLtGzs1xQn60OHSkYohEcqAv+VZ1PNgjiYgNbdwzn9VAE90HJFPEhZ7IW0oWu JX6A== X-Gm-Message-State: AOAM532Q38e0u3Pjkriad9uJD8IN0ndaiA9kgEvH0Yz8i1u7rn5TtRA/ NzZ8zIBzDbpYDRlg6Yf2kBo= X-Google-Smtp-Source: ABdhPJzgH2JupKPauvVNrxewRnPOgZT9DsS7spCYIvNf3mENzkbGKi8D+JbpvRz4e1wSrzR8pbrZeQ== X-Received: by 2002:a92:cf05:: with SMTP id c5mr25905167ilo.225.1620759107543; Tue, 11 May 2021 11:51:47 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:47 -0700 (PDT) From: Jim Cromie To: Arnd Bergmann , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 19/28] dyndbg: RFC handle __dyndbg* sections in module.lds.h Date: Tue, 11 May 2021 12:50:48 -0600 Message-Id: <20210511185057.3815777-20-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=lUOzvKR7; spf=pass (imf08.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.172 as permitted sender) smtp.mailfrom=jimcromie@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: EE65B80192E7 X-Stat-Signature: yeq98hn5eqobyibgnsx3ks84ysg3s7i3 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf08; identity=mailfrom; envelope-from=""; helo=mail-il1-f172.google.com; client-ip=209.85.166.172 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759080-40465 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Up until now, loadable modules have tacitly linked the 2 __dyndbg* sections into the .ko, as observable in log by enabling module.c's pr_debugs and loading a module. But now, we need to explicitly place the header sections in front of their respective __dyndbg* sections, so we reuse input section names for the output. This gives us the placement we need for the header record, which we can see in the "add-module:"s and elements "0 0" below: "0 0" lines are headers: predicate (function==module && !lineno) "X debug prints in" are 1 too high, they count headers. we are adding tables for empty modules (1st 2 below) [ 7.578873] dyndbg: add-module: ghash_clmulni_intel [ 7.579716] dyndbg: 0 0 ghash_clmulni_intel.ghash_clmulni_intel.0 [ 7.608995] dyndbg: 1 debug prints in module ghash_clmulni_intel [ 8.078085] dyndbg: add-module: rapl [ 8.078977] dyndbg: 0 0 rapl.rapl.0 [ 8.079584] dyndbg: 1 debug prints in module rapl [ 8.082009] RAPL PMU: API unit is 2^-32 Joules, 0 fixed counters, 10737418240 ms ovfl timer [ 8.099294] dyndbg: add-module: intel_rapl_common [ 8.100177] dyndbg: 0 0 intel_rapl_common.intel_rapl_common.0 [ 8.101026] dyndbg: 1 1 intel_rapl_common.rapl_remove_package.1279 [ 8.101931] dyndbg: 2 2 intel_rapl_common.rapl_detect_domains.1245 [ 8.102836] dyndbg: 3 3 intel_rapl_common.rapl_detect_domains.1242 [ 8.103778] dyndbg: 4 4 intel_rapl_common.rapl_package_register_powercap.1159 [ 8.104960] dyndbg: 5 5 intel_rapl_common.rapl_package_register_powercap.1145 [ 8.106246] dyndbg: 6 6 intel_rapl_common.rapl_package_register_powercap.1114 [ 8.107302] dyndbg: 7 7 intel_rapl_common.rapl_package_register_powercap.1108 [ 8.108338] dyndbg: 8 8 intel_rapl_common.rapl_update_domain_data.1083 [ 8.109278] dyndbg: 9 9 intel_rapl_common.rapl_check_unit_atom.824 [ 8.110255] dyndbg: 10 10 intel_rapl_common.rapl_check_unit_core.796 [ 8.111361] dyndbg: 11 11 intel_rapl_common.rapl_read_data_raw.722 [ 8.112301] dyndbg: 12 12 intel_rapl_common.contraint_to_pl.303 [ 8.113276] dyndbg: 13 debug prints in module intel_rapl_common [ 8.130452] dyndbg: add-module: intel_rapl_msr [ 8.131140] dyndbg: 0 0 intel_rapl_msr.intel_rapl_msr.0 [ 8.132026] dyndbg: 1 1 intel_rapl_msr.rapl_msr_probe.172 [ 8.132818] dyndbg: 2 2 intel_rapl_msr.rapl_msr_read_raw.104 [ 8.133794] dyndbg: 3 debug prints in module intel_rapl_msr This gives us the property we need: fixed offset from &__dyndbg[N] to &__dyndbg[0] container_of gets &header header has ptr to __dyndbg_sites[] we can (in principle) drop __dyndbg.site ptr (after we adapt header to keep it) TODO: At this point, for loaded modules, ddebug_add_module() sees the header as 0'th element, as we need in order to drop site (and regain worst case footprint parity). It could/should properly init this header to support the _sites[n] lookup for loaded mods. Or at least handle it explicitly. Or at least see what proc-show does with it currently. Note that for builtins, decided by (__start <= dp < __stop), we use __start___dyndbg_sites[N] directly, and dont need the header. But maybe we should use it anyway, double-checking/BUGing when wrong. Signed-off-by: Jim Cromie --- include/asm-generic/module.lds.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/asm-generic/module.lds.h b/include/asm-generic/module.lds.h index f210d5c1b78b..328c48dfc88c 100644 --- a/include/asm-generic/module.lds.h +++ b/include/asm-generic/module.lds.h @@ -4,7 +4,17 @@ /* * can specify arch-specific sections for linking modules. - * Empty for the asm-generic header. + * + * For loadable modules with CONFIG_DYNAMIC_DEBUG, we need to keep the + * 2 __dyndbg* ELF sections, which are loaded by module.c + * + * Pack the 2 __dyndbg* input sections with their respective + * .gnu.linkonce. header records into 2 output sections, with those + * header records in the 0th element. */ +SECTIONS { +__dyndbg_sites : ALIGN(8) { *(.gnu.linkonce.dyndbg_site) *(__dyndbg_sites) } +__dyndbg : ALIGN(8) { *(.gnu.linkonce.dyndbg) *(__dyndbg) } +} #endif /* __ASM_GENERIC_MODULE_LDS_H */ From patchwork Tue May 11 18:50:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251869 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 BA168C43462 for ; Tue, 11 May 2021 18:51:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5BF8261185 for ; Tue, 11 May 2021 18:51:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BF8261185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 265F36B0095; Tue, 11 May 2021 14:51:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CA896B0096; Tue, 11 May 2021 14:51:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC2256B0098; Tue, 11 May 2021 14:51:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0164.hostedemail.com [216.40.44.164]) by kanga.kvack.org (Postfix) with ESMTP id BB3936B0095 for ; Tue, 11 May 2021 14:51:49 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 78C64B9E8 for ; Tue, 11 May 2021 18:51:49 +0000 (UTC) X-FDA: 78129844338.10.7E5CEC8 Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) by imf09.hostedemail.com (Postfix) with ESMTP id F158F6000130 for ; Tue, 11 May 2021 18:51:37 +0000 (UTC) Received: by mail-il1-f182.google.com with SMTP id v13so18058852ilj.8 for ; Tue, 11 May 2021 11:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ThM6By1VCxDqq9nGwswf9Jqgl1+dbifqaaknL7P7lpY=; b=tmaq8Wa2JK6IEvHF8XRUM5s61waWyaSvVWZzIdfvo7JSId8OtSFh7Ma1C6qgIwn2oS WwYEhbYuFKlSpjVld89fGZI1Rtg2+gGE8hjJYTAq4DDLyBJHf0PEKrHa+dpkar72I6N0 qdER3KQymMB3se6FRgiR7LCmE2OnmLLORRfsGXmg5CotrKrXAdzRPmBNbr4U0EkzVU/E Zz+D4lv/qj9UG9tqySAfp/iBjgiCtcaglA70HGaj+Rw+hHQ6CFoE619dGRTnzvRNoaPH SAxprK/47ugoZJkXusyIFnYZ7xhjh39kO8OquPLLxgoDAlUcJsS8R8ewIGwkVyIBSz59 0MbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ThM6By1VCxDqq9nGwswf9Jqgl1+dbifqaaknL7P7lpY=; b=h1aPOMclM8JkbnZLg62ghXBksGdhazKygnRrA5TCOmfwM3s5RUBFlj2j5lBQGXceBx LicQI9YBg/zeCuNdS0JuoLnV6NJlD2cNfY2iHl/QNxhallUYBQualvB3eF8nuiXaF5e9 Q70xoZTdiAOS2GHWNA3PFStaG33ovmUe6/3pUxLeu+NfyJwuTppC8CL9stPdztSD9bd/ oPkubWJrzW26+cSFyAUwNK/i1MogQd0GoBCKnv7kkrBPjHPJaiO30++TQaOz5dwGViqD s/XBKEK9nze+TzHNaB2QPD3VAN2briHnNxNPk+9LxuEO6T3aFi25gH0NkKJOOeqhXwjk AV6g== X-Gm-Message-State: AOAM533nkQr7tE4prGFasnZKTfRntrwUtJ6CQvrogKD2s6z5PdY/E8xU YmSlxB4UXGkGySjXapRTpMo= X-Google-Smtp-Source: ABdhPJwLOoKc8zNucxqD6z3quQIcC5LprrzPcsiI+wTrvE/y1VeX8/ej/ZjJJPcQ87ByMgfGvcqmRg== X-Received: by 2002:a05:6e02:ee1:: with SMTP id j1mr14293787ilk.105.1620759108668; Tue, 11 May 2021 11:51:48 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:48 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 20/28] dyndbg: ddebug_add_module() handle headers. Date: Tue, 11 May 2021 12:50:49 -0600 Message-Id: <20210511185057.3815777-21-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=tmaq8Wa2; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.182 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Stat-Signature: odf1kqo9gamt1zrtcedhg7suamgzkr79 X-Rspamd-Queue-Id: F158F6000130 X-Rspamd-Server: rspam02 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf09; identity=mailfrom; envelope-from=""; helo=mail-il1-f182.google.com; client-ip=209.85.166.182 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759097-64003 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now that header records are in the __dyndbg* sections, ddebug_add_module() sees them when they're present (when adding loadable modules and the 1st builtin, but not 2nd..Nth). Teach ddebug_add_module() to recognize and account for them. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 9d9cb36f40a6..462d364fc788 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1036,7 +1036,18 @@ static int __ddebug_add_module(struct _ddebug *tab, struct _ddebug_site *sites, int i; v3pr_info("add-module: %s.%d sites\n", modname, numdbgs); - if (!numdbgs) { + + if (numdbgs && is_dyndbg_header_pair(tab, sites)) { + + v3pr_info(" header: %d %s.%s.%d\n", tab[0]._index, modname, + tab[0].site->function, tab[0].lineno); + WARN_ON(tab[0].site != &sites[0]); + if (numdbgs <= 1) { + v3pr_info(" skip header %s\n", modname); + return 0; + } + + } else if (!numdbgs) { v3pr_info(" skip %s\n", modname); return 0; } From patchwork Tue May 11 18:50:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251871 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 8D57CC433ED for ; Tue, 11 May 2021 18:52:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1F5DA61185 for ; Tue, 11 May 2021 18:52:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F5DA61185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 91FE56B0096; Tue, 11 May 2021 14:51:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8AB376B009A; Tue, 11 May 2021 14:51:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 55DEA6B0099; Tue, 11 May 2021 14:51:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0020.hostedemail.com [216.40.44.20]) by kanga.kvack.org (Postfix) with ESMTP id D5AAF6B0096 for ; Tue, 11 May 2021 14:51:50 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8C381181AEF3F for ; Tue, 11 May 2021 18:51:50 +0000 (UTC) X-FDA: 78129844380.21.048FF82 Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) by imf10.hostedemail.com (Postfix) with ESMTP id 5E88B40B8CD6 for ; Tue, 11 May 2021 18:51:34 +0000 (UTC) Received: by mail-io1-f50.google.com with SMTP id l21so19199359iob.1 for ; Tue, 11 May 2021 11:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rRjPVWmA3B6C3BJqW3B7XKo1gt0YfFP4dH6JiUaATHk=; b=PxeRlSJXRM39kgpoN6KeFxTZQAnoUhXeu+nclS/M+2kxRYVMqnKV0q8mPVXhZsy5vg Yh5sYX9MBGW2y9AcFZ1bjKw0Bs/7nwpSP8BAgVB0s/YKybhdHVLjCmQj+uVzTw2E8gSA /GwV9kAgYQQmSAG+DHbj9PSZbx273IZBKQ8+WG1K3d1YXJdJNytgE5kvae5mzsALEye8 JKZseRGPK1ajmwV/iBiUZ/uF9J3xUpjr9wkJRgYmuw2LQGuN0zCQXZhnr4Tnmh81BNZR mam5/awoKWy/ovmIvCTSJk5OUHvJ2dVKAkjd4ZmIythBwqosCB89Z8+mXi5quEVICiiX 3GYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rRjPVWmA3B6C3BJqW3B7XKo1gt0YfFP4dH6JiUaATHk=; b=MYUHCNitJBYeokGA9Gtono5KowvHAMrMQ/H2y4RYM4AOm7UG4lidsOG5MzPeYyqwGh iOGzeJIYynViViChRmytjDHE+nUteaWFtc5PLRiFr5uI1rEFvSTFx/cfwcnAyergFNYr AFGy52BrSRVXZkbQCIs8pePcrlHsIV1JLb342SzWsb83vfDSzQtfQCgT03qr6JPMONv6 ETYsqO9RaCJppA7cxQfXgPXkOMpD4WGhJ6sQuHxqhExRALNIfQSG4hevAgAn7NhWeatz Ya58EH+LdUiKRboL9CwbwNLAalGrWwDrFkMIpzUoG465Mstb1Bx6dB5UpiP2hgr4XSvE 3jlw== X-Gm-Message-State: AOAM5331QuTtc/qqg4dLNvCp5yUc0UnnwXaoAqFTFzpry1rRMBHC7zXX CCilUypHw0Hbu2HU2+dZ5C8= X-Google-Smtp-Source: ABdhPJyYx+0zjnNjAY7ZVIA6NDghAsc2PTRQ2e1Uh8OdgjONUFgEIByJt6OJJDrVBkkKQIx3aU/Cug== X-Received: by 2002:a02:ac05:: with SMTP id a5mr28620682jao.89.1620759109684; Tue, 11 May 2021 11:51:49 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:49 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 21/28] dyndbg: validate ddebug_site_get invariants Date: Tue, 11 May 2021 12:50:50 -0600 Message-Id: <20210511185057.3815777-22-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5E88B40B8CD6 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=PxeRlSJX; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf10.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.50 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Rspamd-Server: rspam03 X-Stat-Signature: 78xncmr6y866iojk4xbfmg1ydzq4ocer Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf10; identity=mailfrom; envelope-from=""; helo=mail-io1-f50.google.com; client-ip=209.85.166.50 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759094-777652 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This commit adds several BUG_ONs to assert all the invariants needed to support the reliance on the "back-N-to-header-overto-site-out-N" use of the 2 __dyndbg* vectors (with their included headers). RFC: I don't think we want this permanently; BUG_ON/panic seems kinda overkill, but its useful to know if it survives lkp auto-testing. - dp is (struct _ddebug*) to the callsite, passed in. - dh is (struct _ddebug*) to the header. derived from dp & _index. known by BUG_ON(!is_dyndbg_header(dh)) this is the "up-N-to-header" from dp. - dh has good site pointer, to __dyndbg_sites[] by BUG_ON(!is_dyndbg_header_pair()) There are 2 main cases to validate: builtin and loadable modules. For loadable modules, we will depend upon the headers presence, and its site pointer to the vector of _ddebug_sites[], expressed as: BUG_ON(&dh->site[dp->_index] != dp->site); Builtin pr-debugs have the additional property: !!(&__start___dyndbg <= dp < __stop___dyndbg), We could use this property directly to return site, but since builtin modules also have a header record, we can use that instead. So the 1st BUG_ON is hoisted out of the !builtin branch, and asserted just before return. Also hoist dh derivation, making it a declaration + initialization + BUG_ON instead. NB: grep -- '->site' will confirm that site is now used just for BUG_ON assertions, so we are close to the drop. NEXT To drop site pointer from struct _ddebug, we need: - recast header as a different struct, unionized with _ddebug. - preserve site pointer there. - drop from struct _ddebug. - fix and fold back any fallout from size reduction. OR defer that, and proceed with compressing __dyndbg_sites[], then replacing ddebug_site_get's guts (with all the BUG_ONs) with a decompress and _index. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 462d364fc788..af9791258f8f 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -123,6 +123,8 @@ do { \ #define vpr_info(fmt, ...) vnpr_info(1, fmt, ##__VA_ARGS__) #define v2pr_info(fmt, ...) vnpr_info(2, fmt, ##__VA_ARGS__) #define v3pr_info(fmt, ...) vnpr_info(3, fmt, ##__VA_ARGS__) +#define v4pr_info(fmt, ...) vnpr_info(4, fmt, ##__VA_ARGS__) +#define v5pr_info(fmt, ...) vnpr_info(5, fmt, ##__VA_ARGS__) static void vpr_info_dq(const struct ddebug_query *query, const char *msg) { @@ -146,7 +148,34 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg) static struct _ddebug_site *ddebug_site_get(struct _ddebug *dp) { - return dp->site; /* passthru abstraction */ + struct _ddebug *dh = dp - (dp->_index); + + WARN_ON(!is_dyndbg_header_pair(dh, dh->site)); + + if (dp >= __start___dyndbg && dp < __stop___dyndbg) { + + v5pr_info("get: %s is builtin: %d %d %s:%s:%d\n", + dp->site->modname, dp->_index, (int)(dp - dh), + dh->site[dp->_index].filename, + dh->site[dp->_index].function, dp->lineno); + + WARN_ON(dp != &__start___dyndbg[dp->_index]); + + WARN_ON(!(dp->_index == (dp - dh) && + dp->_index == (dp - __start___dyndbg) && + dp->_index == (&__start___dyndbg_sites[dp->_index] + - &__start___dyndbg_sites[0]))); + + WARN_ON(&__start___dyndbg_sites[dp->_index] != dp->site); + } else { + v4pr_info("get: %s is loaded: %d %s:%s:%d\n", + dp->site->modname, dp->_index, + dh->site[dp->_index].filename, + dh->site[dp->_index].function, dp->lineno); + } + WARN_ON(&dh->site[dp->_index] != dp->site); + + return dp->site; } static inline void ddebug_site_put(struct _ddebug *dp) { From patchwork Tue May 11 18:50:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251873 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 4F473C43600 for ; Tue, 11 May 2021 18:52:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E3C5061185 for ; Tue, 11 May 2021 18:52:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3C5061185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 240106B0099; Tue, 11 May 2021 14:51:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C96A6B009A; Tue, 11 May 2021 14:51:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F12AF6B009B; Tue, 11 May 2021 14:51:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id CC3066B0099 for ; Tue, 11 May 2021 14:51:51 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8602A180275CC for ; Tue, 11 May 2021 18:51:51 +0000 (UTC) X-FDA: 78129844422.28.E107B9F Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by imf22.hostedemail.com (Postfix) with ESMTP id 39169C0001EA for ; Tue, 11 May 2021 18:51:43 +0000 (UTC) Received: by mail-io1-f51.google.com with SMTP id a11so19174175ioo.0 for ; Tue, 11 May 2021 11:51:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v/Ph7k82kiUENJBSQiDSR8itgIh5RXyi6b0YkXaL6Qw=; b=BdHqxobx3i0b8GFby3ylXvLvy5TPzMJHaZElk+Rric9BlIXo/eZoPETSI69DwIDOyb qMzvAlAQ8IQa75MMu3o6phnrh7J2iWj41hr2aTQfhoINsY8bDgSE67fn1w6eLeDz9rPV r4MihMi0N1wvc3cA3R9iAhw/YoTaDHZvzPJ+qtskdkSjfmwligZc/T3ybGAh8DXo50eE IcbrW1wVbCkW/w+kwGKPxbT5ZTSj5fWm+ZkdPAz0coqBZ5KjCIOogdrIzucq+KytsPDB QftccG/y/a3Fkw68Yg+8cIPxLCRpXVBoGtypkty4GZIe4A2zbB2BXt3UtVJn8pwM5EKK fAyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v/Ph7k82kiUENJBSQiDSR8itgIh5RXyi6b0YkXaL6Qw=; b=BSEb7mAtrbJdzj3CXuskp29zgI/i9I2Xxyp8bMc5z4xo3yqETeWBQX0KPvGnDbGd4a XfXKcoQ0TXhru2O68EKAN+Pbq+czIrU6/KXUwCibtOFS/1L4JF6k1DRg8iZGYmJu9DGk 9Q6KfxLZ0X4hiJZDc36ynykmkw+/u+pAakfJApjULPS1x4n3WL0Crktfw9Ahih1dASM8 x55D3yAGKK/VgsJXkmP9nYn5eCFuJlOJOzlRmDzzJUYrKZ8Jn0gCSQ54vE3kjiA007Jg 02Y6AvHI8+4ZIhAo4gfUXaYy2MogqIXDIySyL1paiH+rGMPothSvK8xMjo9+a5YE6+6Y IXew== X-Gm-Message-State: AOAM531ngxFEPhgmUE4ExEwrjI98IowkBzutosOwsNrjdUnyUL7Ee7cj EsAw5bagk/9CgZc3U+erTw1opG6KiR0ok2o4 X-Google-Smtp-Source: ABdhPJw9zXD4acEMCHtf8ziT4UiNL1akEatl5yiLTN/4mh7ecijp7Sy9AyKLLwHBM60t5xCoa+5XEA== X-Received: by 2002:a6b:d10c:: with SMTP id l12mr23361714iob.179.1620759110663; Tue, 11 May 2021 11:51:50 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:50 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 22/28] dyndbg: fix NULL deref after deleting sites Date: Tue, 11 May 2021 12:50:51 -0600 Message-Id: <20210511185057.3815777-23-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=BdHqxobx; spf=pass (imf22.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.51 as permitted sender) smtp.mailfrom=jimcromie@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 39169C0001EA X-Stat-Signature: zrmftsa9zuena6u73k5red7s6ozwb1as Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf22; identity=mailfrom; envelope-from=""; helo=mail-io1-f51.google.com; client-ip=209.85.166.51 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759103-167628 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: After `echo module main +D > control` zeros the site pointer for main's callsites, `cat control` causes a NULL deref in ddebug_site_get(). Fix this with: - in vpr_infos, avoid dp->site->module, use dh->sites[dp->_index] - qualify WARN_ONs that test against dp->site. Also return dp->site, which may be null. This restores the abbreviated control output of deleted sites, rather than pretending it wasnt deleted. Deleting sites isn't an important feature, and its current form will be obsolete when the site pointer gets dropped. Its also pointless if the site data is in compressed blocks. But its still worthwhile to maintain !site robustness for a bit. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index af9791258f8f..d0477450ec0c 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -154,8 +154,8 @@ static struct _ddebug_site *ddebug_site_get(struct _ddebug *dp) if (dp >= __start___dyndbg && dp < __stop___dyndbg) { - v5pr_info("get: %s is builtin: %d %d %s:%s:%d\n", - dp->site->modname, dp->_index, (int)(dp - dh), + v5pr_info("get: %s is builtin: %d %s:%s:%d\n", + dh->site[dp->_index].modname, dp->_index, dh->site[dp->_index].filename, dh->site[dp->_index].function, dp->lineno); @@ -165,15 +165,16 @@ static struct _ddebug_site *ddebug_site_get(struct _ddebug *dp) dp->_index == (dp - __start___dyndbg) && dp->_index == (&__start___dyndbg_sites[dp->_index] - &__start___dyndbg_sites[0]))); - - WARN_ON(&__start___dyndbg_sites[dp->_index] != dp->site); + if (dp->site) + WARN_ON(&__start___dyndbg_sites[dp->_index] != dp->site); } else { v4pr_info("get: %s is loaded: %d %s:%s:%d\n", - dp->site->modname, dp->_index, + dh->site[dp->_index].modname, dp->_index, dh->site[dp->_index].filename, dh->site[dp->_index].function, dp->lineno); } - WARN_ON(&dh->site[dp->_index] != dp->site); + if (dp->site) + WARN_ON(&dh->site[dp->_index] != dp->site); return dp->site; } From patchwork Tue May 11 18:50:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251875 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 62156C433B4 for ; Tue, 11 May 2021 18:52:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E897C611AE for ; Tue, 11 May 2021 18:52:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E897C611AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2DE596B009A; Tue, 11 May 2021 14:51:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 273A66B009B; Tue, 11 May 2021 14:51:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F10156B009C; Tue, 11 May 2021 14:51:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id CF2DB6B009A for ; Tue, 11 May 2021 14:51:52 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 885D0181AEF3F for ; Tue, 11 May 2021 18:51:52 +0000 (UTC) X-FDA: 78129844464.11.18CC609 Received: from mail-il1-f178.google.com (mail-il1-f178.google.com [209.85.166.178]) by imf08.hostedemail.com (Postfix) with ESMTP id 073CB80193AA for ; Tue, 11 May 2021 18:51:24 +0000 (UTC) Received: by mail-il1-f178.google.com with SMTP id z1so10202520ils.0 for ; Tue, 11 May 2021 11:51:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9hgZRYHg+xD/GTpqGrDIeQXKedd/7xSgbcQRecHsrro=; b=Pz4zotfvTBAwUyssz0mfWcsn95ijYGiouDZ0Ib9SBZY8YjkPG+bQjS40T0D9AvOi3z W98YFcMcagS1D4VxIYm8UbzOtxX276ULVpVCMW4adwelIYyQyVglUnbJPUFx9sckGoT7 8yBA8ZJY06fC8W6oB7WhTErVMMv5OMpLgRxss5cBqCaT3dPjQLXdf98WF4kkZjsVVsEB s6vBHAFd6IlklDeEMF/dnYfWJZEP3Hw9KUf2/vnR7RHl0jZW8yT1BpKmNwtt8NFf3ZWJ 3+8PuQKbT0qJy3tGRmEkzn8Gq57AEsfpe2eGPcXwbaufSeHKlmgo/kCXI4gdrunH4n9K d1oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9hgZRYHg+xD/GTpqGrDIeQXKedd/7xSgbcQRecHsrro=; b=U8q77llf1694Orv7CMiGMcBkPT/iCkBJ3/N4hh5ZBvD5rAeun9QxbfapsYSRUFS+bj RfUm1RTNse9XPqLKmtDYlDINOqGK/HBr63hdxir45sxjhWMJEWeZrWy+nz0/U2K+k4AF ZfTQtyMWe3SCztVY9YyP2xWEfE9qkl33sScib3W4UqoCwoT+0uNQvsM2hfBTK4xYW33U oRveIa5BK/FToD6jhC54272R5WRv7Lc+J344gMoOSj+8jv8i/6Dci8uLbU0QT4Im+oI9 AHtuj2l8b8dpCKd7jTFqfypy6qYfiqEwxi9qRNaSGKVecDPY876/7s3zhReeDjCoMs1Y JAJQ== X-Gm-Message-State: AOAM533g29Pgcw1cA719nuw7ucqZbCfrDrW+uvc3q2yqVwNfla6XhUeg H6pmhcwq+gJxbMuxzLaP1p4= X-Google-Smtp-Source: ABdhPJwFe7BCCynBSquUHZ7yLVDDI9YazdXVtAghAHfST2PIv7+SQJcdFDrM5oDltgToXxTjNxVm5w== X-Received: by 2002:a05:6e02:12b3:: with SMTP id f19mr28258870ilr.219.1620759111600; Tue, 11 May 2021 11:51:51 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:51 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 23/28] dyndbg: dont show header records in control Date: Tue, 11 May 2021 12:50:52 -0600 Message-Id: <20210511185057.3815777-24-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 073CB80193AA Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=Pz4zotfv; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.178 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Rspamd-Server: rspam03 X-Stat-Signature: upbk59xba6kwp9efh4m93uxghbi5mm7i Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf08; identity=mailfrom; envelope-from=""; helo=mail-il1-f178.google.com; client-ip=209.85.166.178 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759084-617786 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: header record pairs are special in that the filename member no longer points at string data, but back at the data structure. Theres no reason to expose this in control file, and no reason to even print a line for the header, since its not part of the interface. Printing a "# header" line is a decent alternative, but separate. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index d0477450ec0c..b83187e72ee0 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -995,7 +995,9 @@ static int ddebug_proc_show(struct seq_file *m, void *p) dc = ddebug_site_get(dp); - if (dc) { + if (dc && is_dyndbg_header_pair(dp, dc)) { + /* skip output on header */ + } else if (dc) { seq_printf(m, "%s:%u [%s]%s =%s \"", trim_prefix(dc->filename), dp->lineno, iter->table->mod_name, dc->function, From patchwork Tue May 11 18:50:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251877 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 425B7C433ED for ; Tue, 11 May 2021 18:52:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C9C0761185 for ; Tue, 11 May 2021 18:52:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9C0761185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1A46A6B009B; Tue, 11 May 2021 14:51:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12DA66B009C; Tue, 11 May 2021 14:51:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9BC76B009D; Tue, 11 May 2021 14:51:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0070.hostedemail.com [216.40.44.70]) by kanga.kvack.org (Postfix) with ESMTP id C70B86B009B for ; Tue, 11 May 2021 14:51:53 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 84CE0B7B2 for ; Tue, 11 May 2021 18:51:53 +0000 (UTC) X-FDA: 78129844506.26.583CD14 Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) by imf03.hostedemail.com (Postfix) with ESMTP id 068CBC0007FF for ; Tue, 11 May 2021 18:51:44 +0000 (UTC) Received: by mail-io1-f46.google.com with SMTP id t3so19128942iol.5 for ; Tue, 11 May 2021 11:51:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O0BJdtccf2yAr6b2uo1yZDvtVjzorNp/j0upe7RkRXg=; b=in7nJsUIXuQhI9wTQ88x1zOvaDu7RnqR0Q8idpyFRjxJGrqbIzbZtc1fRGAQ8tcJOb Z5YdMYEvZRsqoq0hSkVmr0YjYhyPXqgh/0tp3c/fPeYWiQcloama1HgWn83/bONGOJJX UwXIiLLRaUs54LNNBnqUFGiBzfT3YdXXDTtAR1K9WrkoE+y+C5XQc2VJ2IMPUv8kd1HZ oTMG0EXWQkg9DTT+NsV3+zu/OmyPkcMTrDfOyUin+sXG0vHwFwFsA/mwVHYkZe0rX4rV +9zh3b4H9ATeAllwC/8iT3Dg6siH2zXbAYuTaAWys1VocRPWUbgEIsBGEOVoXs0xiLnT 4Zaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O0BJdtccf2yAr6b2uo1yZDvtVjzorNp/j0upe7RkRXg=; b=TilKYEiygV3+MQAHa35kJlK5+oN+HMnQaaWVo/pGtB7VAlffEVf8kITQSSpcokdtiA 01tMBt1nkRD5y3irIGwXjD/QdmFJrxFh+mLP+IZVIy2CCN/J7O5y/jtImTZq8OXaSX7p cQ4d2qnk6ZhUwzHgjwRWC8LY5RXKeLVpbgkJrW/MG016mFxWRilt0geYIoTbh3CwYnoV ZVePRdPIpT/oRysh4efy4H4zgMt9RkJNngIhltEkv6qgEJ90ZyT3ZBkQX3hWAgCIBBR4 JTyj2iIt2T4CP9Pz+gHl98ieaO047RdToSyIDTcbT4xedVqYc4HYG+x6o5Lmjo0c8GmN 8PMg== X-Gm-Message-State: AOAM531M2ddX2DxqDXGknZJ0NAj6Cnbx6LgTkDWl66aRd9Le5FVWToxF V2tc4t94rC1reziXWQzeJPU= X-Google-Smtp-Source: ABdhPJz85XfrSMdeQNwF8K/Ub1WdvZ+s3Hf15DIDmS9kxaJYqeQ4vTjfWj1GV0Z3rzimZH5IsK5q3w== X-Received: by 2002:a05:6602:2002:: with SMTP id y2mr8570269iod.70.1620759112554; Tue, 11 May 2021 11:51:52 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:52 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 24/28] dyndbg: make site pointer and checks on it optional (not quite) Date: Tue, 11 May 2021 12:50:53 -0600 Message-Id: <20210511185057.3815777-25-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=in7nJsUI; spf=pass (imf03.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.46 as permitted sender) smtp.mailfrom=jimcromie@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 068CBC0007FF X-Stat-Signature: 5w85tnt6yhb8xtssrbi1jnpcnng961zg Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf03; identity=mailfrom; envelope-from=""; helo=mail-io1-f46.google.com; client-ip=209.85.166.46 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759104-182400 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Wrap declaration and uses of _ddebug.site pointer in ifdefs. Mostly, this eliminates all the WARN_ONs in ddebug_site_get(), which seem to be mostly proven (they were BUG_ONs). This adds macro indirection around ifdef SITE_CHK; adding SITE_INIT_ to adjust the .site initializations, and SITE_COND, which abstracts a logic test used by is_dyndbg_header_pair(i,s). TODO: breaks when !defined SITE_CHK - the header, being just a struct _ddebug, also lost the .site member. Need to specialize the header struct, then unionize it back in. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 20 ++++++++++++++++---- lib/dynamic_debug.c | 13 ++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 06ae1d8d8c10..46901b5348ee 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -6,6 +6,18 @@ #include #endif +#define SITE_CHK /* include .site pointer and checks on it */ + +#ifdef SITE_CHK +#define SITE_CHK_(...) __VA_ARGS__ +#define SITE_COND(_i, _s) (_s == _i->site) +#define SITE_INIT_(_name) .site = &_name, +#else +#define SITE_CHK_(...) +#define SITE_COND(_i, _s) (true) +#define SITE_INIT_(name) +#endif + /* * A pair of these structs are created in 2 special ELF sections * (__dyndbg, __dyndbg_sites) for every dynamic debug callsite. @@ -25,7 +37,7 @@ struct _ddebug_site { } __aligned(8); struct _ddebug { - struct _ddebug_site *site; + SITE_CHK_(struct _ddebug_site *site;) /* format is always needed, lineno shares word with flags */ const char *format; const unsigned lineno:18; @@ -106,7 +118,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, }; \ static struct _ddebug __aligned(8) \ __section("__dyndbg") name = { \ - .site = &name##_site, \ + SITE_INIT_(name##_site) \ .format = (fmt), \ .lineno = __LINE__, \ .flags = _DPRINTK_FLAGS_DEFAULT, \ @@ -138,13 +150,13 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, __weak struct _ddebug __used __aligned(8) \ __section(".gnu.linkonce.dyndbg") \ _LINKONCE_dyndbg_header = { \ - .site = &_LINKONCE_dyndbg_site_header, \ + SITE_INIT_(_LINKONCE_dyndbg_site_header) \ .format = KBUILD_MODNAME \ } /* The header initializations as a distinguishing predicate */ #define is_dyndbg_header_pair(iter, sitep) \ - (sitep == iter->site \ + (SITE_COND(iter, sitep) \ && (!iter->lineno) \ && (iter->format == sitep->modname) \ && (sitep->modname == sitep->function) \ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index b83187e72ee0..9551c0d406b6 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -151,7 +151,7 @@ static struct _ddebug_site *ddebug_site_get(struct _ddebug *dp) struct _ddebug *dh = dp - (dp->_index); WARN_ON(!is_dyndbg_header_pair(dh, dh->site)); - +#ifdef SITE_CHK if (dp >= __start___dyndbg && dp < __stop___dyndbg) { v5pr_info("get: %s is builtin: %d %s:%s:%d\n", @@ -177,6 +177,9 @@ static struct _ddebug_site *ddebug_site_get(struct _ddebug *dp) WARN_ON(&dh->site[dp->_index] != dp->site); return dp->site; +#else + return &dh->site[dp->_index]; +#endif } static inline void ddebug_site_put(struct _ddebug *dp) { @@ -241,6 +244,7 @@ static void ddebug_alter_site(struct _ddebug *dp, } else if (modifiers->flags & _DPRINTK_FLAGS_PRINT) static_branch_enable(&dp->key.dd_key_true); #endif +#ifdef SITE_CHK /* delete site info for this callsite */ if (modifiers->flags & _DPRINTK_FLAGS_DELETE_SITE) { if (dp->site) { @@ -249,6 +253,7 @@ static void ddebug_alter_site(struct _ddebug *dp, dp->site = NULL; } } +#endif } /* @@ -1073,7 +1078,9 @@ static int __ddebug_add_module(struct _ddebug *tab, struct _ddebug_site *sites, v3pr_info(" header: %d %s.%s.%d\n", tab[0]._index, modname, tab[0].site->function, tab[0].lineno); - WARN_ON(tab[0].site != &sites[0]); + + SITE_CHK_(BUG_ON(tab[0].site != &sites[0])); + if (numdbgs <= 1) { v3pr_info(" skip header %s\n", modname); return 0; @@ -1251,7 +1258,7 @@ static int __init dynamic_debug_init(void) for (i = 0; iter < __stop___dyndbg; iter++, site++, i++) { - WARN_ON(site != iter->site); + SITE_CHK_(WARN_ON(site != iter->site)); if (strcmp(modname, site->modname)) { modct++; From patchwork Tue May 11 18:50:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251879 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 25961C433B4 for ; Tue, 11 May 2021 18:52:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B1B2161185 for ; Tue, 11 May 2021 18:52:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1B2161185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 157096B009C; Tue, 11 May 2021 14:51:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 092426B009D; Tue, 11 May 2021 14:51:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD9A66B009E; Tue, 11 May 2021 14:51:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0241.hostedemail.com [216.40.44.241]) by kanga.kvack.org (Postfix) with ESMTP id B2D546B009C for ; Tue, 11 May 2021 14:51:54 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7BC808E6B for ; Tue, 11 May 2021 18:51:54 +0000 (UTC) X-FDA: 78129844548.21.217A79A Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) by imf28.hostedemail.com (Postfix) with ESMTP id DEBDD2000381 for ; Tue, 11 May 2021 18:51:52 +0000 (UTC) Received: by mail-io1-f54.google.com with SMTP id p11so19131701iob.9 for ; Tue, 11 May 2021 11:51:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JFW2fUV4S5apIt9TXKZGsIObebJdVsdqxjr+w7oZ8PM=; b=RfUMTS3QpJFUFcAuMUlC8ssDrXbEgtr6q0lOQAdiw1HvMLTzyWgIZYcuODtR8Fbf78 m1yaR9wN4oiYEILIACopoVY0/AXoqgMun99SLLAoO3MfAaHp0lXRW6xQk0sBV1boC9Jk 2c0UBOkZBLulplheqFYC8UzWTuF2Ehp4RcbU3VPno8BO+IIFCGWu2Po1yZDi0VBkW1ZV qFw3NDehnyNl65ZfVkM2TBiVxTwZNlbXRX+nN+NbstV4Wwz6+wJrwOQucJv8wqSOSPmQ nGbytwYVuH8/T6b0j12kdFqc6bED9EtY6Qed9nkIEik2C45w+dFe6l+IuT+qijsh2cfE 25/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JFW2fUV4S5apIt9TXKZGsIObebJdVsdqxjr+w7oZ8PM=; b=Rp+THAW+B9aTqdnwPpuqfASgVVBRmWmz8lcVW++iO/I7NeZt7lP2XNBy78+AU4bV2G ZZCuYXqFdN8AWY0TVHlAccYymhFtgcOaX+QOV4RHgzsMvu0oCksEGZzkFvZr7zLzQiKy rTqK42gnH9vngk6qLQRR8/E5SnHrLeGYcnjticYHqijmp8sPZ/sjqi97of/ZmoQ2p7s2 fqw9leYQlPUVuSvKktggAMt8/8s9shY3+h3ZRil52pr1yBVx/tZ/P4XdUSViWzDK0Kko jnqrCmg76azSvqOa+CA9TFk6DLwjk2tzfH4GnwAp/StznXTBClGzdhnQLmNQzTTTP+Df d8wA== X-Gm-Message-State: AOAM531fc0HWQQoQIHcH2PJEj7z5hcEK09pPYIiB+erEmS8SPsPf74U8 svUSv1wHg/4XUUuw1VGKXy8p1HSK8oSpMDw4 X-Google-Smtp-Source: ABdhPJwG3LrJGqKaLiX+OEv4jKy41DuSJAb4+ZcfJENAHIi33C9Iw/TKSXmtOBL0T2srd2dCBmgS9Q== X-Received: by 2002:a02:b057:: with SMTP id q23mr6582814jah.25.1620759113627; Tue, 11 May 2021 11:51:53 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:53 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 25/28] dyndbg: swap WARN_ON for BUG_ON see what 0-day says Date: Tue, 11 May 2021 12:50:54 -0600 Message-Id: <20210511185057.3815777-26-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: DEBDD2000381 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=RfUMTS3Q; spf=pass (imf28.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.54 as permitted sender) smtp.mailfrom=jimcromie@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Stat-Signature: hnq7yfmwk6ta16q3iuq9ifztyyk1wuf9 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf28; identity=mailfrom; envelope-from=""; helo=mail-io1-f54.google.com; client-ip=209.85.166.54 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759112-988801 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: HEAD~1 passed 0-day, Im not sure what it does with WARNs, so make everything fatal, see what dies. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 9551c0d406b6..b61e4a211819 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -150,7 +150,7 @@ static struct _ddebug_site *ddebug_site_get(struct _ddebug *dp) { struct _ddebug *dh = dp - (dp->_index); - WARN_ON(!is_dyndbg_header_pair(dh, dh->site)); + BUG_ON(!is_dyndbg_header_pair(dh, dh->site)); #ifdef SITE_CHK if (dp >= __start___dyndbg && dp < __stop___dyndbg) { @@ -159,14 +159,14 @@ static struct _ddebug_site *ddebug_site_get(struct _ddebug *dp) dh->site[dp->_index].filename, dh->site[dp->_index].function, dp->lineno); - WARN_ON(dp != &__start___dyndbg[dp->_index]); + BUG_ON(dp != &__start___dyndbg[dp->_index]); - WARN_ON(!(dp->_index == (dp - dh) && + BUG_ON(!(dp->_index == (dp - dh) && dp->_index == (dp - __start___dyndbg) && dp->_index == (&__start___dyndbg_sites[dp->_index] - &__start___dyndbg_sites[0]))); if (dp->site) - WARN_ON(&__start___dyndbg_sites[dp->_index] != dp->site); + BUG_ON(&__start___dyndbg_sites[dp->_index] != dp->site); } else { v4pr_info("get: %s is loaded: %d %s:%s:%d\n", dh->site[dp->_index].modname, dp->_index, @@ -174,7 +174,7 @@ static struct _ddebug_site *ddebug_site_get(struct _ddebug *dp) dh->site[dp->_index].function, dp->lineno); } if (dp->site) - WARN_ON(&dh->site[dp->_index] != dp->site); + BUG_ON(&dh->site[dp->_index] != dp->site); return dp->site; #else @@ -1258,7 +1258,7 @@ static int __init dynamic_debug_init(void) for (i = 0; iter < __stop___dyndbg; iter++, site++, i++) { - SITE_CHK_(WARN_ON(site != iter->site)); + SITE_CHK_(BUG_ON(site != iter->site)); if (strcmp(modname, site->modname)) { modct++; From patchwork Tue May 11 18:50:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251881 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 0983EC433B4 for ; Tue, 11 May 2021 18:52:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9302061185 for ; Tue, 11 May 2021 18:52:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9302061185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 32AA66B009D; Tue, 11 May 2021 14:51:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DD306B009E; Tue, 11 May 2021 14:51:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E99B46B009F; Tue, 11 May 2021 14:51:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0123.hostedemail.com [216.40.44.123]) by kanga.kvack.org (Postfix) with ESMTP id C5FBE6B009D for ; Tue, 11 May 2021 14:51:55 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8E5038249980 for ; Tue, 11 May 2021 18:51:55 +0000 (UTC) X-FDA: 78129844590.07.22B47DB Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) by imf28.hostedemail.com (Postfix) with ESMTP id E4B922000262 for ; Tue, 11 May 2021 18:51:53 +0000 (UTC) Received: by mail-il1-f171.google.com with SMTP id h6so18058371ila.7 for ; Tue, 11 May 2021 11:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lMrLgXjSzOGMax97ZAjPuKjPWtjxj0H1kJUreDJDf+w=; b=LEtG3ihOA1BViOl2QB/R2JmFpF3C23P8wC0ZzJFslcqKz2UrjjfCGSMJSZ8d5JuAZB fHWgRuGyWHmKSKwlSndj5lmEaIStkgSWtfAb7asoRdchxqocGr876VkqJQiPKbmzc/+E cP25XOK8KD/Q70a/FpEJgMhg3/Q9toAFwQOQ71K7rUz3YRbEtO12QnGP/FtY0bEa0nn8 FtTxbXtkcVE5b+LFB04U1w8c15n5Duy72KlKDW4vpQttr3tkiG4s2FV3Z40bLCb7M/Xj VXFoaTIEd2QyQBfBF9ni1MN+rqaZSfaN+gwuaW1TgntbaJnzSvlhflL2mxX/RXUxa5Wz RgUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lMrLgXjSzOGMax97ZAjPuKjPWtjxj0H1kJUreDJDf+w=; b=XP/vWD+g1JtvHMMMNfMi24Ai4wFWShh5XX83RJw8o1+ixhWos7Ome2A1hYZIw1IOs7 g6i9zLpSwYBCMtiHKEtcOp2n5LR1Lzw3a28+MA6iCa0trRoOGsbh93qaEVY9yCMOQasg C/jG3X1c6pIecvaWMCc2kxBiq9BHa8BQ28y+2tmeI9whw15JzO+bvWCKDJDbCsuJV7KZ rYCha/UuW+FMPT5vz6dvXL/jvOEwn40amkiqLbxrAWPRvzrTluikwoody3+Ug8QSSVKZ nC40/eUJmujUGySG2zZVWQeHAWjPtRyD52Qa0mEg+gCWmbckGAgg1txXjvb9u+OJnMld Mupg== X-Gm-Message-State: AOAM531yuJbAHbjqjt3fu59VadOJYaRNjvwFGScMqQDgztxlyA2rkj+6 a5Yi72xZ1GGEhNZiseNzRPURcVuqvk8+WrYR X-Google-Smtp-Source: ABdhPJxiVnpBHXyE95wUwqbPhaWCA00yUSuhwPCB3oYg2FrrasNkc6LPoAY8ZEZxTAHZQ5jrtpxklA== X-Received: by 2002:a92:d3c1:: with SMTP id c1mr27604342ilh.21.1620759114551; Tue, 11 May 2021 11:51:54 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:54 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 26/28] dyndbg: fixup protect header when deleting site Date: Tue, 11 May 2021 12:50:55 -0600 Message-Id: <20210511185057.3815777-27-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=LEtG3ihO; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.171 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Stat-Signature: co6sosjopknz3j86u39sicireujgjqhy X-Rspamd-Queue-Id: E4B922000262 X-Rspamd-Server: rspam02 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf28; identity=mailfrom; envelope-from=""; helo=mail-il1-f171.google.com; client-ip=209.85.166.171 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759113-159016 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: fix a null-ptr-deref when .site info is deleted. #> echo +D > /proc/dynamic_debug/control This protects the header.site pointer from zeroing; we need it for all the SITE_CHK sanity checking. Probably should protect against toggling the static_key too (in the same function), but this smaller change fixes the crash. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index b61e4a211819..aa4a476d70ad 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -247,7 +247,7 @@ static void ddebug_alter_site(struct _ddebug *dp, #ifdef SITE_CHK /* delete site info for this callsite */ if (modifiers->flags & _DPRINTK_FLAGS_DELETE_SITE) { - if (dp->site) { + if (dp->site && !is_dyndbg_header_pair(dp, dp->site)) { vpr_info("dropping site info %s.%s.%d\n", dp->site->filename, dp->site->function, dp->lineno); dp->site = NULL; From patchwork Tue May 11 18:50:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251883 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 20E24C433B4 for ; Tue, 11 May 2021 18:52:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A0E3C61185 for ; Tue, 11 May 2021 18:52:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A0E3C61185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 21CA76B009E; Tue, 11 May 2021 14:51:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A9016B009F; Tue, 11 May 2021 14:51:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F0F8A6B00A0; Tue, 11 May 2021 14:51:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0173.hostedemail.com [216.40.44.173]) by kanga.kvack.org (Postfix) with ESMTP id CE4136B009E for ; Tue, 11 May 2021 14:51:56 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8481A180275CC for ; Tue, 11 May 2021 18:51:56 +0000 (UTC) X-FDA: 78129844632.36.CB48FF8 Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) by imf12.hostedemail.com (Postfix) with ESMTP id 0F366F9 for ; Tue, 11 May 2021 18:51:39 +0000 (UTC) Received: by mail-il1-f174.google.com with SMTP id j20so18029129ilo.10 for ; Tue, 11 May 2021 11:51:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RetV73+gjmatQ10AYA8JVaODMFVKb7GL6Z0yeYfciDg=; b=fRIuCpEZT5toBeJSxRcZygcC8hRLmM9HlDEtdBqsGTt4k5QJA4Puu2+YFFwsLKN7/5 mdNeZJmc0P8fhWS43um5qEISx4cqn/3thn0zsUihATIkz8KQ8EtSRchQw8Iy7l0JpeDV 6mLurHEdKhFjq+GZN6mKsu2ypF8V9dYG+z3AFIO4AlmmoVfEwYVVbwHx8YrkLzeTPS14 23X0nd4gEH/uyaYaZZfAqITHS4j9FkmOe23MWa/cvxlNZsjzSFg33Qn09/FEQ3iza0Fu lsj3CHOeAaS0rGbviepfMq0SxifOyC6rvKnV42TEyYGLYjWzRihoWlidLK0GS22CXTKP UjBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RetV73+gjmatQ10AYA8JVaODMFVKb7GL6Z0yeYfciDg=; b=ecD0diASsPh6Ew+IimTjmFRACPoSRDZFEcWNs6ulqTcoDjRvTt8SUBRb4HQnSXHhUA u7tF94B+ztvbElwqDDFmFV7c4+Hs3b+s900/x4qHfsGZOomPAjgYH+uqzOyWZGIOFIE1 UVjZ1NB/9qV2GjdoUkS8t1H507XVoWkc70XW8L6mK1btC1Nk8JBf65AHTPpp/0iw5IiV eOUaCH+qGzQU5ID33tljcwGTM1MxisfNaTxlyci1VAty0EAGUMMmq2tMAzLvkpCCqFBc nYsgDG5z1nYl8jI01KZjmwMufqS12pe/Qo5565Jwt9uka0kS9I0FGf6F2g5Vt4F4qRmy wGtA== X-Gm-Message-State: AOAM5312ZhorA0Vm8/pLC0MkMFRr40/a3WREs8jQ0Lhra3SyFsGPIl2v z9N0WnISS1P0WI0fiKxDHak= X-Google-Smtp-Source: ABdhPJxqhsB2v+ubkXoKuKBuZ58V3W7JR1ZIHk3WyB51m5HA5YvDAVqhizjZsfGdclze8KcHYlAwiA== X-Received: by 2002:a92:1a12:: with SMTP id a18mr27991241ila.168.1620759115477; Tue, 11 May 2021 11:51:55 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:55 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 27/28] dyndbg: unionize _ddebug*_headers with struct _ddebug* Date: Tue, 11 May 2021 12:50:56 -0600 Message-Id: <20210511185057.3815777-28-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0F366F9 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=fRIuCpEZ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.174 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Rspamd-Server: rspam03 X-Stat-Signature: 8w4p7mhomxmd1hwa3e9hppkt1619n8m6 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf12; identity=mailfrom; envelope-from=""; helo=mail-il1-f174.google.com; client-ip=209.85.166.174 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759099-551653 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Up until now, to create our header record (pair), we reused struct _ddebug(|_sites), initializing the pair with "impossible" field values (for a pr_debug() site), which makes it recognizable as a header not a pr-debug callsite. Now we want to specialize the header; differentiate it from its model, then we can drop _ddebug.site, and use header.site indirectly. This commit has several elements combining: Update DEFINE_DYNAMIC_DEBUG_TABLE by replacing "struct _ddebug*" with "union _ddebug*_header". This change places the new object types into our 2 elf sections. our 2 new union types have 2 jobs: a.fit properly in the section/array. We do this by putting the struct inside the union, making the unions the same size as their contained structs. This was sufficient to fix a data-misalignment crash on 2nd loop (ie 1st record after header) in _init. b.unions need the same field defns as their models, as refd in: DEFINE_DYNAMIC_DEBUG_TABLE() - inits is_dyndbg_header_pair(i,s) - validates that init use anonymous struct. RFC: My "anonymous union/struct fu" feels incomplete. The struct in b must contain all the fields of its outer union's own contained struct, maybe even in the same order (tho not obvious yet). Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 46901b5348ee..9ca413985fb2 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -36,6 +36,16 @@ struct _ddebug_site { const char *function; } __aligned(8); +/* verbatim copy of struct _ddebug_site. nothing to save here. */ +union _ddebug_site_header { + struct _ddebug_site __; /* inherit footprint */ + struct { /* header validation */ + const char *modname; + const char *filename; + const char *function; + }; +}; + struct _ddebug { SITE_CHK_(struct _ddebug_site *site;) /* format is always needed, lineno shares word with flags */ @@ -74,6 +84,21 @@ struct _ddebug { #endif } __aligned(8); +/* + * specialized version of struct _ddebug. The only field we NEED is + * .site, since keeping it here allows dropping from struct _ddebug + * itself. format, lineno are used to validate header records. + */ +union _ddebug_header { + struct _ddebug __; /* inherit footprint */ + struct { /* header validation */ + union _ddebug_site_header *site; + const char *format; + const unsigned lineno:18; + unsigned _index:14; + unsigned int flags:8; + }; +}; #if defined(CONFIG_DYNAMIC_DEBUG_CORE) @@ -136,10 +161,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, */ #define DEFINE_DYNAMIC_DEBUG_TABLE() \ /* forward decl, allowing loopback pointer */ \ - __weak struct _ddebug __used __aligned(8) \ + __weak union _ddebug_header __used __aligned(8) \ __section(".gnu.linkonce.dyndbg") \ _LINKONCE_dyndbg_header; \ - __weak struct _ddebug_site __used __aligned(8) \ + __weak union _ddebug_site_header __used __aligned(8) \ __section(".gnu.linkonce.dyndbg_site") \ _LINKONCE_dyndbg_site_header = { \ .modname = KBUILD_MODNAME, \ @@ -147,7 +172,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, /* forced pointer loopback, for distinction */ \ .filename = (void *) &_LINKONCE_dyndbg_header \ }; \ - __weak struct _ddebug __used __aligned(8) \ + __weak union _ddebug_header __used __aligned(8) \ __section(".gnu.linkonce.dyndbg") \ _LINKONCE_dyndbg_header = { \ SITE_INIT_(_LINKONCE_dyndbg_site_header) \ From patchwork Tue May 11 18:50:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12251885 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 171D5C433B4 for ; Tue, 11 May 2021 18:52:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A252B61185 for ; Tue, 11 May 2021 18:52:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A252B61185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E28066B009F; Tue, 11 May 2021 14:51:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DAF5F6B00A0; Tue, 11 May 2021 14:51:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B664D8D0001; Tue, 11 May 2021 14:51:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id 90AC96B009F for ; Tue, 11 May 2021 14:51:57 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5904D8249980 for ; Tue, 11 May 2021 18:51:57 +0000 (UTC) X-FDA: 78129844674.24.A102357 Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) by imf04.hostedemail.com (Postfix) with ESMTP id 9609B3E1 for ; Tue, 11 May 2021 18:51:50 +0000 (UTC) Received: by mail-il1-f177.google.com with SMTP id s9so788292ilp.9 for ; Tue, 11 May 2021 11:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w/MStH6rleojLv6FsPubLujifVnUutNTi0UTvEWgL70=; b=n0w1LLoKmwiskrevRxDlHMcMz0ItQvFgP4Mm/+gUC3Hp2n1gu9Wu8t1tjnP2fFWVdF MCf/6W3GMlxHEjyKcSIeRZqJGegNFHbpGto8pZz8nrjz8BSQt6E2Ndv1wiQfIvz5SDN4 C0tuwP/5MfQ4mkeailcv+3URknXWfvSTiXqz1962+ABfNbpXUMJiH6o9B3+E7t3FM1n+ wlEoObEB5kWpLDoyBKGnByn6Aw4Ui9eoBwWwqY4HRrrlroXY0PKfVQYHcScf7ExTPOVf GE2BaTLnwq6vJwG7/NS9Ule3fb1rqoIw23Ki3j6GFKDU/xsAEuWixpSZJ6jnlNAHJv30 jmDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w/MStH6rleojLv6FsPubLujifVnUutNTi0UTvEWgL70=; b=g/eb1NeogS5+p3cU/eir6z4uxmacHyD7w7L16ApGQDmJUsahkvbOCwfsg3kY1hsEhO jWHLu9VxT9Wi7DihRpRJTyNHc95VcbKBvGxQpgDOjlTHn0zjHWHGPqr7urzUafmySuuM hWKJmq22+Z0FmyKrt/oh+LK9G1h0aTNGfcH6dQyO4hQ76zNedXQBvEi9h/9UHm/FfGTP hBpr+rQovMP7cnbzP+OTYM0oqCreoML/gFf/Sttn5W2/IZY586derUSJfB7e29ifDslo gfjau7UlzyK99DiUP2u3SzyV23xnLGQVxx3JUWNt3EiWots3rVgzLrMbauRwNOh30b73 xU+w== X-Gm-Message-State: AOAM533iqrVmrPspvlrplgrVeIZhAdqJ/aMHdbqMooT98XQwNyLIPqRc H24l5+fIChoME+sNY+RGOww= X-Google-Smtp-Source: ABdhPJxZIho9S9YRnlHrZ1rQU5B1tlKuVPPKUeHaGibAuu93uqCrmR1pZxVkYnI/ke59YOgpp2ttqA== X-Received: by 2002:a92:c846:: with SMTP id b6mr23449530ilq.68.1620759116365; Tue, 11 May 2021 11:51:56 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:56 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 28/28] dyndbg: RFC drop _ddebug.site pointer Date: Tue, 11 May 2021 12:50:57 -0600 Message-Id: <20210511185057.3815777-29-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9609B3E1 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=n0w1LLoK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.177 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Rspamd-Server: rspam03 X-Stat-Signature: frjmes41a36pnpazumd7mtsdmunjdunb Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf04; identity=mailfrom; envelope-from=""; helo=mail-il1-f177.google.com; client-ip=209.85.166.177 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759110-327870 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In .h, flip the switch on #define SITE_CHK. This finally removes the _ddebug.site pointer, and all uses of it. Due to this, the .site cross-link done by DEFINE_DYNAMIC_DEBUG_METADATA() is lost to the compiler, so suppress the resulting warnings by adding a "__used" to the _ddebug_site records initialized there. In .c, fix a bunch of fallout: - mostly casts from struct to/from union - convert a BUG_ON to a WARN, it happens ~20x per `cat control`, probably headers on loaded modules - fixup missing _ddebug_header.site, bad initialization of some sort. This seems to work, but should be cleaner. RFC Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 4 ++-- lib/dynamic_debug.c | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 9ca413985fb2..7f2b255a25ae 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -6,7 +6,7 @@ #include #endif -#define SITE_CHK /* include .site pointer and checks on it */ +// #define SITE_CHK /* include .site pointer and checks on it */ #ifdef SITE_CHK #define SITE_CHK_(...) __VA_ARGS__ @@ -135,7 +135,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, const char *fmt, ...); #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ - static struct _ddebug_site __aligned(8) \ + static struct _ddebug_site __aligned(8) __used \ __section("__dyndbg_sites") name##_site = { \ .modname = KBUILD_MODNAME, \ .filename = __FILE__, \ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index aa4a476d70ad..db759c998c54 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -148,9 +148,12 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg) static struct _ddebug_site *ddebug_site_get(struct _ddebug *dp) { - struct _ddebug *dh = dp - (dp->_index); + union _ddebug_header *dh = (union _ddebug_header *) (dp - dp->_index); + + if (!is_dyndbg_header_pair(dh, dh->site)) { + v3pr_info("get: header fail\n"); + } - BUG_ON(!is_dyndbg_header_pair(dh, dh->site)); #ifdef SITE_CHK if (dp >= __start___dyndbg && dp < __stop___dyndbg) { @@ -178,7 +181,7 @@ static struct _ddebug_site *ddebug_site_get(struct _ddebug *dp) return dp->site; #else - return &dh->site[dp->_index]; + return (struct _ddebug_site *) &dh->site[dp->_index]; #endif } static inline void ddebug_site_put(struct _ddebug *dp) @@ -1070,17 +1073,23 @@ static int __ddebug_add_module(struct _ddebug *tab, struct _ddebug_site *sites, const char *modname) { struct ddebug_table *dt; + union _ddebug_header *dh = (union _ddebug_header *) &tab[0]; int i; v3pr_info("add-module: %s.%d sites\n", modname, numdbgs); - if (numdbgs && is_dyndbg_header_pair(tab, sites)) { + if (numdbgs && is_dyndbg_header_pair(dh, sites)) { - v3pr_info(" header: %d %s.%s.%d\n", tab[0]._index, modname, - tab[0].site->function, tab[0].lineno); + v3pr_info(" header: %d %s.\n", dh->_index, modname); - SITE_CHK_(BUG_ON(tab[0].site != &sites[0])); + SITE_CHK_(BUG_ON(dh->site[0] != &sites[0])); + /* for !SITE_CHK, need to set site ptr, fixup missed init! */ + if (!dh->site) { + dh->site = (union _ddebug_site_header *) sites; + v3pr_info(" header: %d %s.%s.%d\n", dh->_index, modname, + dh->site->function, dh->lineno); + } if (numdbgs <= 1) { v3pr_info(" skip header %s\n", modname); return 0; @@ -1110,7 +1119,7 @@ static int __ddebug_add_module(struct _ddebug *tab, struct _ddebug_site *sites, for (i = 0; i < numdbgs; i++, base++) { tab[i]._index = base; v3pr_info(" %d %d %s.%s.%d\n", i, base, modname, - tab[i].site->function, tab[i].lineno); + sites[i].function, tab[i].lineno); } mutex_lock(&ddebug_lock);