Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp27627748rwd; Tue, 4 Jul 2023 05:47:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlHMgrUt94yLpqgTZJC+NwOlF9KF57kb53+8BxXi3GmNaN/uc1ssdoMgxtlyldx+Kxx/GPHo X-Received: by 2002:a17:903:2304:b0:1b6:b703:36f8 with SMTP id d4-20020a170903230400b001b6b70336f8mr21981923plh.25.1688474830713; Tue, 04 Jul 2023 05:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688474830; cv=none; d=google.com; s=arc-20160816; b=qouPxZgOYuy4vPCCiIpfDLBeu7lA/rrf477IAoGfpjZCEGGqlvUW+hl5Ty6THiwuOg YOK5EaCFn0BnSpriM0gEhegz7U7FNmNz9DaWF5XXnIPtdMG66I0Ft5kPFO6DpD6Tff3Q ZG9QgrCiZP9U9e2bSIB3DxyCzmOrV8fddLZqa90imoWVriFG5fv3l01EJIEtc2dyzUm2 tmFThNQ/OojhM916lekPmTJlHp+3hZf4d4eRPNZmarDK6luSOPH1rLKmtuoespW+2xFl 5Elnb1tI+v/E1POyEbGPiMUvhIsI4IocJxaDShDnOAOibkAAnpoSSjmDMwe5psZ9kmMD EFIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature:dkim-signature; bh=kyeDVjvHSYtTDluOfRyuRMUOaldUOiI9fDr6cfh4oxA=; fh=qBRsGWTfP1dT7xGjN6s+l4PguGFhwrvqFqqF9Y8TA7k=; b=MT8n2nATo+gYMzYI9iv7QRFxyAn3uAOCJFtSszOE45ojE4SEmW06D1osXjWR+rGRgq fhGK2PruRXUj+G6NaI5cYWOiKrQkSQR/w9h4djSbs3zp2p11lA1Bt/eGS/cDLF1nGXuM SlgW/rBShEvnoTwvCkpfo5ELYxAcqGnrBcQy7rzpvS2AdM5/1JHLa3pGdNih9FqTqgq/ u8JeGI7pBqRVp9TN/Ig2YC7qaep4+RrtK9S0DeHgyNx/tR7OaG8unhitculC/Adfmvyv QPClClv1PYKv49AqK2d/Iuxt7XumyqPLzY/0FVh1cpDx7Qe0rj9euPa9Z0Ehc+7TnVVP Te/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=1V2Hu6Zz; dkim=neutral (no key) header.i=@suse.de; 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=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u13-20020a170903124d00b001ae7f85061bsi21879770plh.609.2023.07.04.05.46.56; Tue, 04 Jul 2023 05:47:10 -0700 (PDT) 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=@suse.de header.s=susede2_rsa header.b=1V2Hu6Zz; dkim=neutral (no key) header.i=@suse.de; 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=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231349AbjGDMnR (ORCPT + 99 others); Tue, 4 Jul 2023 08:43:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbjGDMnQ (ORCPT ); Tue, 4 Jul 2023 08:43:16 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B01F9FB; Tue, 4 Jul 2023 05:43:15 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 70A8C228AF; Tue, 4 Jul 2023 12:43:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1688474594; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kyeDVjvHSYtTDluOfRyuRMUOaldUOiI9fDr6cfh4oxA=; b=1V2Hu6Zzpq7keu28Xq6HSHZUlf3pJxJTZNcMG1H9l4pgXrGfOEy37dp3yfcnZxx95duHKk WuSGXFxF28KbgD3OJsmu5ZS0FgbsGfkZeq+lqNMcdgIpRG5LBrC9imL/pjoWDruLt3abjI jGmoxAK04b7LiiSO2CCKtuEso8+o/ro= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1688474594; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kyeDVjvHSYtTDluOfRyuRMUOaldUOiI9fDr6cfh4oxA=; b=M48thlqgS+JjQCHXafM3BN0IIDaNEs91CKvO2wLd5f7s0EKdHc1CeU1W7NKMpNKxGX7op2 gIpgDbxtd28uc1CA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 405071346D; Tue, 4 Jul 2023 12:43:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UPX1DeITpGQeOwAAMHmgww (envelope-from ); Tue, 04 Jul 2023 12:43:14 +0000 Date: Tue, 4 Jul 2023 14:43:12 +0200 From: Jean Delvare To: Michal Hocko Cc: Luis Chamberlain , linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] module: print module name on refcount error Message-ID: <20230704144312.032b4ddd@endymion.delvare> In-Reply-To: References: <20230626123252.73dbc139@endymion.delvare> Organization: SUSE Linux X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.34; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Hi Michal, On Wed, 28 Jun 2023 12:30:35 +0200, Michal Hocko wrote: > On Mon 26-06-23 12:32:52, Jean Delvare wrote: > > If module_put() triggers a refcount error, include the culprit > > module name in the warning message, to easy further investigation of > > the issue. > > > > Signed-off-by: Jean Delvare > > Suggested-by: Michal Hocko > > Cc: Luis Chamberlain > > --- > > kernel/module/main.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > --- linux-6.3.orig/kernel/module/main.c > > +++ linux-6.3/kernel/module/main.c > > @@ -850,7 +850,9 @@ void module_put(struct module *module) > > if (module) { > > preempt_disable(); > > ret = atomic_dec_if_positive(&module->refcnt); > > - WARN_ON(ret < 0); /* Failed to put refcount */ > > + WARN(ret < 0, > > + KERN_WARNING "Failed to put refcount for module %s\n", > > + module->name); > > Would it make sense to also print the refcnt here? In our internal bug > report it has turned out that this was an overflow (put missing) rather > than an underflow (too many put calls). Seeing the value could give a > clue about that. We had to configure panic_on_warn to capture a dump to > learn more which is rather impractical. Well, other calls to module_put() or try_module_get() could happen in parallel, so at the time we print refcnt, its value could be different from the one which triggered the WARN. Additionally, catching an overflow in module_put() is counterintuitive, it only works by accident because the counter gets to negative values. If we really want to reliably report overflows as such then we should add a dedicated WARN to try_module_get(). Doesn't look trivial though. With my proposed implementation, I don't think it's necessary to turn on panic_on_warn to debug further. Once you know which module is culprit, enabling tracing for this specific module should give you all the details you need to figure out what's going on. -- Jean Delvare SUSE L3 Support