Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1250603rdb; Sun, 7 Jan 2024 10:21:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IFG/BaJz6flqtk9Pd2sqWFi3UfsDExIPzIiRCChB46YUJ9oTBd44QQUujLc1KcVb+q6IGBr X-Received: by 2002:a05:6a20:889e:b0:199:a747:d77c with SMTP id d30-20020a056a20889e00b00199a747d77cmr932091pzf.48.1704651676042; Sun, 07 Jan 2024 10:21:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704651676; cv=none; d=google.com; s=arc-20160816; b=s9mKe36vGyGjN/mOF0t8Qg6/2fJQhE1p6hnQltCL1lsdWb7EmYjEW/7qWiPnq0LszN N1Yr37WcWLLDH0SrEISNe/FZwEH+p3pcps1dJex96AwRVehm4tNSc7wybTDMHhE6f1FX 12BgcvLSHb1Vjz6njsB5qRnAkFtoJObj1jrS+9rclooOw1geml99LVPLWS3/irS5T5qg gFxQhIq4vnDlTxsVxiJGrEP1u/rzWYXc+L4Z7IyRcQnbFbsITpy6XLRDfUPKhnpTlizm SgBOp0+0BQC2wBgcujR6W6ZDWcbPRyeAInKetug3ZaPZUEiQd9Gb/xB6BvYIB8rBOKIm qBcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=XLM19rnFHzBJvnyekc58tcfOzt/S7QfB6XAL0a9O+j4=; fh=3YNAVALVkn68NlL2jt3P+5ddvHI4PXsUHp5xSRVbJj0=; b=x0V/Gk2x3MPg4juZLYVRgAYwuQXcBPlrOtM+cojezZntU56VcGlm0VL277TuWn7BUc uX+Y4QHWHnXQIPEcEKFaukDW2FBFwjkVN3Rx/I6eewbuhZ3BugxVkqZ7erLrhlgm+29e qVZPJnuO44KIJQoIwqL0x9Fa8TgsaYk7lBuGNPufO6h0XnDfnFMO9G15KqzH9piq3KGm MAG6MI/7HlAAI0Wdjtzz1RXZEhMn1u9QiqaA4t9+OaIMEKKxaPbxDaIY+V8/4EcMJ/3j Jkoaw1vi1PPNW/9sr5SGM2oPDy8i+9YCkaQowzv5Rwo/SaEZIpn6fNbCDvq/majr1CEL 1m1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=dwENUuli; spf=pass (google.com: domain of linux-kernel+bounces-18948-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18948-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i5-20020a636d05000000b005c69765acddsi4758966pgc.87.2024.01.07.10.21.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jan 2024 10:21:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18948-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=dwENUuli; spf=pass (google.com: domain of linux-kernel+bounces-18948-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18948-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 68537B2131A for ; Sun, 7 Jan 2024 18:21:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D478613FFA; Sun, 7 Jan 2024 18:21:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="dwENUuli" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABB3E13FF0 for ; Sun, 7 Jan 2024 18:21:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF2FDC433C8; Sun, 7 Jan 2024 18:21:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1704651664; bh=sZPBGcFilnJgnQg/CYPYjTdMMjgjwjmQd4ivbtePeo8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=dwENUuliYF0nyFc92wP0odwzDw6aRV3mytuf+PZjrGFOYpUd7Ezxyeyxi0wk2Egpx osKfrTzGM/WcEL+7B5syCr0rK7pRVC4IbMyNWOH8JVJqqPxICMNKtKrZpyoCg3FaRc 7NwZy+Vj0O8vpxN6eARxoDrgbjPmTUSe/5FtLDIk= Date: Sun, 7 Jan 2024 10:21:03 -0800 From: Andrew Morton To: Baoquan He Cc: linux-kernel@vger.kernel.org, pmladek@suse.com, gcc@gcc.gnu.org Subject: Re: [PATCH] panic: suppress gnu_printf warning Message-Id: <20240107102103.3c0ba0cfa4df37df4b59090e@linux-foundation.org> In-Reply-To: <20240107091641.579849-1-bhe@redhat.com> References: <20240107091641.579849-1-bhe@redhat.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Sun, 7 Jan 2024 17:16:41 +0800 Baoquan He wrote: > with GCC 13.2.1 and W=1, there's compiling warning like this: > > kernel/panic.c: In function ‘__warn’: > kernel/panic.c:676:17: warning: function ‘__warn’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format] > 676 | vprintk(args->fmt, args->args); > | ^~~~~~~ > > The normal __printf(x,y) adding can't fix it. So add workaround which > disables -Wsuggest-attribute=format to mute it. > > ... > > --- a/kernel/panic.c > +++ b/kernel/panic.c > @@ -666,8 +666,13 @@ void __warn(const char *file, int line, void *caller, unsigned taint, > pr_warn("WARNING: CPU: %d PID: %d at %pS\n", > raw_smp_processor_id(), current->pid, caller); > > +#pragma GCC diagnostic push > +#ifndef __clang__ > +#pragma GCC diagnostic ignored "-Wsuggest-attribute=format" > +#endif > if (args) > vprintk(args->fmt, args->args); > +#pragma GCC diagnostic pop > > print_modules(); __warn() clearly isn't such a candidate. I'm suspecting that gcc's implementation of this warning is pretty crude. Is it a new thing in gcc-13.2? A bit of context for gcc@gcc.gnu.org: struct warn_args { const char *fmt; va_list args; }; ... void __warn(const char *file, int line, void *caller, unsigned taint, struct pt_regs *regs, struct warn_args *args) { disable_trace_on_warning(); if (file) pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS\n", raw_smp_processor_id(), current->pid, file, line, caller); else pr_warn("WARNING: CPU: %d PID: %d at %pS\n", raw_smp_processor_id(), current->pid, caller); if (args) vprintk(args->fmt, args->args); print_modules(); if (regs) show_regs(regs); check_panic_on_warn("kernel"); if (!regs) dump_stack(); print_irqtrace_events(current); print_oops_end_marker(); trace_error_report_end(ERROR_DETECTOR_WARN, (unsigned long)caller); /* Just a warning, don't kill lockdep. */ add_taint(taint, LOCKDEP_STILL_OK); }