From patchwork Tue Feb 28 19:34:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Baron X-Patchwork-Id: 62592 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3232512wrd; Tue, 28 Feb 2023 12:16:54 -0800 (PST) X-Google-Smtp-Source: AK7set+5lU/jthx1JyXKv+lPmLIeBgEK99aKXLkbw6xc5HcY56QPVffl7yI+dnkWFbHN6ZkLj4fC X-Received: by 2002:a17:907:2495:b0:8ac:8f3c:7f65 with SMTP id zg21-20020a170907249500b008ac8f3c7f65mr4087582ejb.48.1677615414612; Tue, 28 Feb 2023 12:16:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677615414; cv=none; d=google.com; s=arc-20160816; b=QJkvOKjOSZUMMpCGnNw39NEtOXtg2dvcpFgDWCqVd8dRNTHCnc2Y9JS06+b/NSfUF2 fjZzdd8T+Ct3iY7KG6KEXg0EvWbfxto6RQbEDOCyfXQaEvD5oE5eKdOyIZx+imixIf/q Q5+zHRh4Isw2vTUffFKjkGyK4kUu01q3+Ktl8Ph63M+EgYOmyOXouXfsjysIMmUjtA1O +mkPig1kvl73haJrfV/km9S3bAIHXzj52yUqmMYNq5R2QeHyvKKKp1BWgOyIaCuXzzQ9 mu1pxMN2QZ+rHzRYodAaKaXVX7qs1El/52sxv9wHInOEiZ+rH7nAPh6OHexpVpQF5EaY hAxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=YOlQK+46DJKYK6TKdktXOrnFvwYoVuQ6cgNrlLTlTWo=; b=Oa+bbURsVF2qiep37SkTI+PF0pmOl7Uw1ZdK8tYbbj5UAmv59e1D6IFvUdFzCGiK2B BfNmpgRAeXiZ2FSckzLirJ1Yml9Zm0Xe83Ze6IHwP1MafE7thO7M6VcAqlDB17e7dUxj dE2bDWtCRTkEhDz0v3cYifndptUpnDAryMC8tDVLSGhimjjZ/QAW7h4YfXxK1PLcpvOF 4luEEROBkHYx9o7sQY84HwIOjQ5stLWtbSlfAV3LX72uy0Q8B+h1YKPXnVz0Q/PCuOS5 /8qGvP4Ha5LQtn+flVVYmkNrwTlh/OF+Tv9tuP1YuX8HDH34QDniD6sg1AWeZx93L2Yv EGRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@akamai.com header.s=jan2016.eng header.b="Vh0/QunG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j12-20020a170906278c00b008da5d744f15si586488ejc.815.2023.02.28.12.16.08; Tue, 28 Feb 2023 12:16:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@akamai.com header.s=jan2016.eng header.b="Vh0/QunG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229990AbjB1T66 (ORCPT + 99 others); Tue, 28 Feb 2023 14:58:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229728AbjB1T64 (ORCPT ); Tue, 28 Feb 2023 14:58:56 -0500 X-Greylist: delayed 1450 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 28 Feb 2023 11:58:52 PST Received: from mx0b-00190b01.pphosted.com (mx0b-00190b01.pphosted.com [IPv6:2620:100:9005:57f::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A3F8211F2; Tue, 28 Feb 2023 11:58:52 -0800 (PST) Received: from pps.filterd (m0050102.ppops.net [127.0.0.1]) by m0050102.ppops.net-00190b01. (8.17.1.19/8.17.1.19) with ESMTP id 31SFcO7Y032202; Tue, 28 Feb 2023 19:34:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : in-reply-to : references; s=jan2016.eng; bh=YOlQK+46DJKYK6TKdktXOrnFvwYoVuQ6cgNrlLTlTWo=; b=Vh0/QunG3oaF0KqXB/tGJJF2jMkab2El7kBdCGkoDeUVm4iw+e354nrD+SPzXzGpovTW 2nz7tYgpor2ZGZe0y6LF/K3TEwWew/1SU0KdzpvObXhgWcM2+pdOLjewgTeNeUu9ySUM lgR263GMZo0F5ZSO9FjmgnbGazGGvb4oJE6wVlsJUwXBmHHl41hbB7nd8knYmTGjboXT 7nZX8vjG9qVx9TgVJqJjGRbByhkNsBOQXJFxetv8zeivbtUDln+sEBN+0u44ajxDVBRQ Z8nVAr3VN/9ixrmfn6hzXTCpsHd1gLlTLRiD1JYal9SCO+5bLEJHfO6zmtTFIFP7zHD5 gA== Received: from prod-mail-ppoint4 (a72-247-45-32.deploy.static.akamaitechnologies.com [72.247.45.32] (may be forged)) by m0050102.ppops.net-00190b01. (PPS) with ESMTPS id 3ny89q6d9x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Feb 2023 19:34:41 +0000 Received: from pps.filterd (prod-mail-ppoint4.akamai.com [127.0.0.1]) by prod-mail-ppoint4.akamai.com (8.17.1.19/8.17.1.19) with ESMTP id 31SFoUZP017426; Tue, 28 Feb 2023 14:34:40 -0500 Received: from prod-mail-relay19.dfw02.corp.akamai.com ([172.27.165.173]) by prod-mail-ppoint4.akamai.com (PPS) with ESMTP id 3nyej3vwg2-1; Tue, 28 Feb 2023 14:34:40 -0500 Received: from bos-lhv9ol.bos01.corp.akamai.com (bos-lhv9ol.bos01.corp.akamai.com [172.28.222.101]) by prod-mail-relay19.dfw02.corp.akamai.com (Postfix) with ESMTP id 2470160207; Tue, 28 Feb 2023 19:34:40 +0000 (GMT) From: Jason Baron To: jim.cromie@gmail.com Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org Subject: [PATCH v2 1/2] dyndbg: remove unused 'base' arg from __ddebug_add_module() Date: Tue, 28 Feb 2023 14:34:21 -0500 Message-Id: <855201dc0204a1428a79d415c97df2b6e11c95c3.1677612539.git.jbaron@akamai.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-02-28_17,2023-02-28_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302280162 X-Proofpoint-GUID: X2RkHrAwvsg98I6acqzS2dBrqDELXsGB X-Proofpoint-ORIG-GUID: X2RkHrAwvsg98I6acqzS2dBrqDELXsGB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-02-28_17,2023-02-28_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 impostorscore=0 bulkscore=0 suspectscore=0 spamscore=0 malwarescore=0 mlxlogscore=990 priorityscore=1501 clxscore=1015 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302280162 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759107260914084275?= X-GMAIL-MSGID: =?utf-8?q?1759107260914084275?= __ddebug_add_module() doesn't use the 'base' arg. Remove it. Cc: Jim Cromie Cc: Greg Kroah-Hartman Tested-by: Jim Cromie Signed-off-by: Jason Baron Reviewed-by: Vincenzo Palazzo --- lib/dynamic_debug.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 009f2ead09c1..8136e5236b7b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1223,8 +1223,7 @@ static void ddebug_attach_module_classes(struct ddebug_table *dt, * Allocate a new ddebug_table for the given module * and add it to the global list. */ -static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, - const char *modname) +static int __ddebug_add_module(struct _ddebug_info *di, const char *modname) { struct ddebug_table *dt; @@ -1265,7 +1264,7 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, int ddebug_add_module(struct _ddebug_info *di, const char *modname) { - return __ddebug_add_module(di, 0, modname); + return __ddebug_add_module(di, modname); } /* helper for ddebug_dyndbg_(boot|module)_param_cb */ @@ -1408,7 +1407,7 @@ static int __init dynamic_debug_init(void) mod_ct++; di.num_descs = mod_sites; di.descs = iter_mod_start; - ret = __ddebug_add_module(&di, i - mod_sites, modname); + ret = __ddebug_add_module(&di, modname); if (ret) goto out_err; @@ -1419,7 +1418,7 @@ static int __init dynamic_debug_init(void) } di.num_descs = mod_sites; di.descs = iter_mod_start; - ret = __ddebug_add_module(&di, i - mod_sites, modname); + ret = __ddebug_add_module(&di, modname); if (ret) goto out_err; From patchwork Tue Feb 28 19:35:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Baron X-Patchwork-Id: 62590 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3215732wrd; Tue, 28 Feb 2023 11:44:08 -0800 (PST) X-Google-Smtp-Source: AK7set+5MoNmxqITLIbgekwm/BeP2oRuEMWWjpHVyI2WAYNBJNu67akbLG6MEnzKXRTu/nHPao6O X-Received: by 2002:a05:6a21:6d8a:b0:cc:c69b:f7f1 with SMTP id wl10-20020a056a216d8a00b000ccc69bf7f1mr4957140pzb.15.1677613448140; Tue, 28 Feb 2023 11:44:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677613448; cv=none; d=google.com; s=arc-20160816; b=hfUWPrGn9CSw4R3r2ce4EN2+2Bf++rjpVValAPXUXvuig80rVPfm5zNLuvOT3slDlI nxYLSPN1KvoJxkcJOtS9POpypOLV8+zCJVtp2F+bkqL5klQq3dHvoXdBsT50V94002NZ to7A/gnR+Ixh0ukjVTh1TR0muEPSXSglxkUr4+U6voNanUYsdx0rNNNq4FowFosE6TB0 rSbSD01yD1wEnKcA5h6gBuHvHhhmx7DdmHrkZbnPGUqkadKrkpk0Zk0UG1VveRZy+oh1 1RNZd00gt2zyhEa0X7cZZXJccIEUUEcUw+HzIBRaR8cqc6jj4rRlFtAlVlzzgJAyOb1+ 1sPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=FXBN8z0b5l4H0NA8PqL/u0B1NC7g5qJCA4eYy2c/ins=; b=MU1A0mpgUokF6vsUe4lkH/3skwyowYThf33wrRJ4MsNddc/7SK8qvYbm3OUMymHNRs TYKCyqbKsWeYepy76hoWGCkaio1WQTOuRH22IluhTx9ZaW5rQh2ZsNbrbuMK82EgnYL7 CqhKb/M0KiIMjdXLXqyR9Otjz6MO1UI8IZtPJjtFGAeycXvTZat5OhQNCPmrDbr9efjr 15gOdS5sp+Zt7kZ0sVTVN1TFuYl9/pHtLZm2/pU85IN6f+92usKMuWmWkml6oR+0PzZV LKX8VaZ3sEVOY37JSUfvstuh/NHa2ovxPKFbZPrbmPNSiCVSbz5RLZN+5MPl8dbRuBb7 8/Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@akamai.com header.s=jan2016.eng header.b=V6fvEit7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i185-20020a6387c2000000b004fb6f10cd3asi1554742pge.871.2023.02.28.11.43.54; Tue, 28 Feb 2023 11:44:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@akamai.com header.s=jan2016.eng header.b=V6fvEit7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbjB1Tfq (ORCPT + 99 others); Tue, 28 Feb 2023 14:35:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229691AbjB1Tfo (ORCPT ); Tue, 28 Feb 2023 14:35:44 -0500 Received: from mx0a-00190b01.pphosted.com (mx0a-00190b01.pphosted.com [IPv6:2620:100:9001:583::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87021268C; Tue, 28 Feb 2023 11:35:42 -0800 (PST) Received: from pps.filterd (m0050093.ppops.net [127.0.0.1]) by m0050093.ppops.net-00190b01. (8.17.1.19/8.17.1.19) with ESMTP id 31SFVkrf019282; Tue, 28 Feb 2023 19:35:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=jan2016.eng; bh=FXBN8z0b5l4H0NA8PqL/u0B1NC7g5qJCA4eYy2c/ins=; b=V6fvEit7NAkeMj9miQM/TdXQ6SWUdBh7rc8/DsVctZPpx7r1XubdxPd66xljqhxxAzuT /Tixs9Cl1JcrKL/YJcQWykxyvtuRpVWGI4oeSuFYWwk7GobnyLkBg85+Wxp0KgoVcM2g ObT2RVZIFmRX1hXQNj+SOu0/LKwjG799rp5D9kZo6khI77u5JN2MnD4Lek7r7jJ3oaB+ KIQFj7Y6wv5DqPU+cROAP0bSrGbstsz0oSyxYQhdWWcnofG3Xy4nNNWPOFg6UM4Ofgoq FUcLZkNrsRG995/jc3nPWmTTkU5i6PI9Z1b29IOLLx+RegeYCZUaS0mORUgLEM44vWxc Sg== Received: from prod-mail-ppoint4 (a72-247-45-32.deploy.static.akamaitechnologies.com [72.247.45.32] (may be forged)) by m0050093.ppops.net-00190b01. (PPS) with ESMTPS id 3nyag0ufru-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Feb 2023 19:35:23 +0000 Received: from pps.filterd (prod-mail-ppoint4.akamai.com [127.0.0.1]) by prod-mail-ppoint4.akamai.com (8.17.1.19/8.17.1.19) with ESMTP id 31SFq8WR017441; Tue, 28 Feb 2023 14:35:22 -0500 Received: from prod-mail-relay18.dfw02.corp.akamai.com ([172.27.165.172]) by prod-mail-ppoint4.akamai.com (PPS) with ESMTP id 3nyej3vwjy-1; Tue, 28 Feb 2023 14:35:22 -0500 Received: from bos-lhv9ol.bos01.corp.akamai.com (unknown [172.28.222.101]) by prod-mail-relay18.dfw02.corp.akamai.com (Postfix) with ESMTP id E8E4780; Tue, 28 Feb 2023 19:35:16 +0000 (GMT) From: Jason Baron To: jim.cromie@gmail.com Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, Peter Zijlstra , Luis Chamberlain Subject: [PATCH v2 2/2] dyndbg: use the module notifier callbacks Date: Tue, 28 Feb 2023 14:35:02 -0500 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-02-28_17,2023-02-28_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 mlxlogscore=705 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302280162 X-Proofpoint-GUID: guf5aP1NqYGck38bCJxjFBABhTsQD2og X-Proofpoint-ORIG-GUID: guf5aP1NqYGck38bCJxjFBABhTsQD2og X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-02-28_17,2023-02-28_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=632 spamscore=0 malwarescore=0 suspectscore=0 bulkscore=0 phishscore=0 adultscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302280161 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759105198563275602?= X-GMAIL-MSGID: =?utf-8?q?1759105198563275602?= As part of Jim Cromie's new dynamic debug classmap feature, the new code tries to toggle a jump label from dynamic_debug_setup(). However, dynamic_debug_setup() is called before the 'module_notify_list' notifier chain is invoked. And jump labels are initialized via the module notifier chain. Note this is an issue for a new feature not yet merged and doesn't affect any existing codepaths. We could just move dynamic_debug_setup() earlier in load_module(). But let's instead ensure the ordering via the 'priority' in the module list notifier. This brings dynamic debug more in line with other subsystems and pulls code out of the core module code. Link: https://lore.kernel.org/lkml/20230113193016.749791-21-jim.cromie@gmail.com/ Reported-by: kernel test robot Link: https://lore.kernel.org/oe-kbuild-all/202302190427.9iIK2NfJ-lkp@intel.com/ Tested-by: Jim Cromie Cc: Peter Zijlstra CC: Jim Cromie Cc: Luis Chamberlain Cc: Greg Kroah-Hartman Signed-off-by: Jason Baron --- include/linux/dynamic_debug.h | 13 --------- include/linux/module.h | 4 +++ kernel/module/internal.h | 2 -- kernel/module/main.c | 30 ++++++--------------- lib/dynamic_debug.c | 50 ++++++++++++++++++++++++++++------- 5 files changed, 53 insertions(+), 46 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 41682278d2e8..f401414341fb 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -130,9 +130,6 @@ struct ddebug_class_param { #if defined(CONFIG_DYNAMIC_DEBUG_CORE) -int ddebug_add_module(struct _ddebug_info *dyndbg, 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, ...); @@ -304,16 +301,6 @@ int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp); #include #include -static inline int ddebug_add_module(struct _ddebug_info *dinfo, const char *modname) -{ - return 0; -} - -static inline int ddebug_remove_module(const char *mod) -{ - return 0; -} - static inline int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *modname) { diff --git a/include/linux/module.h b/include/linux/module.h index 8c5909c0076c..87d4ccc79445 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -546,6 +547,9 @@ struct module { struct error_injection_entry *ei_funcs; unsigned int num_ei_funcs; #endif +#ifdef CONFIG_DYNAMIC_DEBUG_CORE + struct _ddebug_info dyndbg_info; +#endif } ____cacheline_aligned __randomize_layout; #ifndef MODULE_ARCH_INIT #define MODULE_ARCH_INIT {} diff --git a/kernel/module/internal.h b/kernel/module/internal.h index 2e2bf236f558..7366fcf89103 100644 --- a/kernel/module/internal.h +++ b/kernel/module/internal.h @@ -53,7 +53,6 @@ extern const struct kernel_symbol __stop___ksymtab_gpl[]; extern const s32 __start___kcrctab[]; extern const s32 __start___kcrctab_gpl[]; -#include struct load_info { const char *name; /* pointer to module in temporary copy, freed at end of load_module() */ @@ -63,7 +62,6 @@ struct load_info { Elf_Shdr *sechdrs; char *secstrings, *strtab; unsigned long symoffs, stroffs, init_typeoffs, core_typeoffs; - struct _ddebug_info dyndbg; bool sig_ok; #ifdef CONFIG_KALLSYMS unsigned long mod_kallsyms_init_off; diff --git a/kernel/module/main.c b/kernel/module/main.c index 4ac3fe43e6c8..cd5e401e4dc3 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -1157,9 +1157,6 @@ static void free_module(struct module *mod) mod->state = MODULE_STATE_UNFORMED; mutex_unlock(&module_mutex); - /* Remove dynamic debug info */ - ddebug_remove_module(mod->name); - /* Arch-specific cleanup. */ module_arch_cleanup(mod); @@ -1591,19 +1588,6 @@ static void free_modinfo(struct module *mod) } } -static void dynamic_debug_setup(struct module *mod, struct _ddebug_info *dyndbg) -{ - if (!dyndbg->num_descs) - return; - ddebug_add_module(dyndbg, mod->name); -} - -static void dynamic_debug_remove(struct module *mod, struct _ddebug_info *dyndbg) -{ - if (dyndbg->num_descs) - ddebug_remove_module(mod->name); -} - void * __weak module_alloc(unsigned long size) { return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END, @@ -2109,10 +2093,14 @@ static int find_module_sections(struct module *mod, struct load_info *info) if (section_addr(info, "__obsparm")) pr_warn("%s: Ignoring obsolete parameters\n", mod->name); - info->dyndbg.descs = section_objs(info, "__dyndbg", - sizeof(*info->dyndbg.descs), &info->dyndbg.num_descs); - info->dyndbg.classes = section_objs(info, "__dyndbg_classes", - sizeof(*info->dyndbg.classes), &info->dyndbg.num_classes); +#ifdef CONFIG_DYNAMIC_DEBUG_CORE + mod->dyndbg_info.descs = section_objs(info, "__dyndbg", + sizeof(*mod->dyndbg_info.descs), + &mod->dyndbg_info.num_descs); + mod->dyndbg_info.classes = section_objs(info, "__dyndbg_classes", + sizeof(*mod->dyndbg_info.classes), + &mod->dyndbg_info.num_classes); +#endif return 0; } @@ -2824,7 +2812,6 @@ static int load_module(struct load_info *info, const char __user *uargs, } init_build_id(mod, info); - dynamic_debug_setup(mod, &info->dyndbg); /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */ ftrace_module_init(mod); @@ -2888,7 +2875,6 @@ static int load_module(struct load_info *info, const char __user *uargs, ddebug_cleanup: ftrace_release_mod(mod); - dynamic_debug_remove(mod, &info->dyndbg); synchronize_rcu(); kfree(mod->args); free_arch_cleanup: diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 8136e5236b7b..fdd6d9800a70 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1223,7 +1223,7 @@ static void ddebug_attach_module_classes(struct ddebug_table *dt, * Allocate a new ddebug_table for the given module * and add it to the global list. */ -static int __ddebug_add_module(struct _ddebug_info *di, const char *modname) +static int ddebug_add_module(struct _ddebug_info *di, const char *modname) { struct ddebug_table *dt; @@ -1262,11 +1262,6 @@ static int __ddebug_add_module(struct _ddebug_info *di, const char *modname) return 0; } -int ddebug_add_module(struct _ddebug_info *di, const char *modname) -{ - return __ddebug_add_module(di, 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) @@ -1313,11 +1308,13 @@ static void ddebug_table_free(struct ddebug_table *dt) kfree(dt); } +#ifdef CONFIG_MODULES + /* * Called in response to a module being unloaded. Removes * any ddebug_table's which point at the module. */ -int ddebug_remove_module(const char *mod_name) +static int ddebug_remove_module(const char *mod_name) { struct ddebug_table *dt, *nextdt; int ret = -ENOENT; @@ -1336,6 +1333,33 @@ int ddebug_remove_module(const char *mod_name) return ret; } +static int ddebug_module_notify(struct notifier_block *self, unsigned long val, + void *data) +{ + struct module *mod = data; + int ret = 0; + + switch (val) { + case MODULE_STATE_COMING: + ret = ddebug_add_module(&mod->dyndbg_info, mod->name); + if (ret) + WARN(1, "Failed to allocate memory: dyndbg may not work properly.\n"); + break; + case MODULE_STATE_GOING: + ddebug_remove_module(mod->name); + break; + } + + return notifier_from_errno(ret); +} + +static struct notifier_block ddebug_module_nb = { + .notifier_call = ddebug_module_notify, + .priority = 0, /* dynamic debug depends on jump label */ +}; + +#endif /* CONFIG_MODULES */ + static void ddebug_remove_all_tables(void) { mutex_lock(&ddebug_lock); @@ -1387,6 +1411,14 @@ static int __init dynamic_debug_init(void) .num_classes = __stop___dyndbg_classes - __start___dyndbg_classes, }; +#ifdef CONFIG_MODULES + ret = register_module_notifier(&ddebug_module_nb); + if (ret) { + pr_warn("Failed to register dynamic debug module notifier\n"); + return ret; + } +#endif /* CONFIG_MODULES */ + if (&__start___dyndbg == &__stop___dyndbg) { if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n"); @@ -1407,7 +1439,7 @@ static int __init dynamic_debug_init(void) mod_ct++; di.num_descs = mod_sites; di.descs = iter_mod_start; - ret = __ddebug_add_module(&di, modname); + ret = ddebug_add_module(&di, modname); if (ret) goto out_err; @@ -1418,7 +1450,7 @@ static int __init dynamic_debug_init(void) } di.num_descs = mod_sites; di.descs = iter_mod_start; - ret = __ddebug_add_module(&di, modname); + ret = ddebug_add_module(&di, modname); if (ret) goto out_err;