From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 8205E3858D35 for ; Mon, 8 Jan 2024 01:56:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8205E3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8205E3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704679001; cv=none; b=cwpo8lRijaV75T3Z7bls+ExgoCPn+tjMZQk+0OT7xrH75UsGXoQGe79nQ6RFn1xy6k/WuV4s2jVKv6PChZBLr7lpgMZwtr52lKCjr6nB3A7CmBKhAwHCqhCkQ5QYRXYjyIyKhpYAFYQTILHjbPVaxBhkoyet+tcnMAl1hJokaJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704679001; c=relaxed/simple; bh=d++NIamcWcvp6B+eltZORHsg4j32jQHtgJ06X9kF0Pk=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=oj84RLH6XbYNorus8CfJ8sVC6CMIEj1n3e6yKP1uIbsTd0MUEQfoslhHWB8C8KqTprpg4GNCH8KPQZiLf73+ZtEJG5zC9uKlZqmFTVdhF8ryLDd4Dg/hA3Tksd/jarTF/92MQZYX7/Sa8x+SKqzEtj16ZbI0EOkEC3VqYPoRMJ4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704678997; h=from:from:reply-to:subject:subject: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=IrZ5E7rRsnkdiBF4vqSGlathax6Dq7mNMmU4TVzIiFM=; b=bob+1OpIIIIdFC0wdFVKmO/4Q3mCEdBc5lX/Pg59bfjOXW4JQ2iJpSqz0KqGDVgD9w9/go v8VwEtrOozwAWu6JhwA94bsKBYctNwa6mNkiIT9vSV5g6OkLqPWTwwHWaNELIFcz5imCRO LjPOWZvXsybTI8kY3G7e8DHBS5FuCU4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-161-S81HB8pKPXCiYUqLv1fNCA-1; Sun, 07 Jan 2024 20:56:33 -0500 X-MC-Unique: S81HB8pKPXCiYUqLv1fNCA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 431268489E7; Mon, 8 Jan 2024 01:56:33 +0000 (UTC) Received: from localhost (unknown [10.72.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 98F912166B33; Mon, 8 Jan 2024 01:56:32 +0000 (UTC) Date: Mon, 8 Jan 2024 09:56:29 +0800 From: Baoquan He To: Andrew Morton Cc: linux-kernel@vger.kernel.org, pmladek@suse.com, gcc@gcc.gnu.org Subject: Re: [PATCH] panic: suppress gnu_printf warning Message-ID: References: <20240107091641.579849-1-bhe@redhat.com> <20240107102103.3c0ba0cfa4df37df4b59090e@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240107102103.3c0ba0cfa4df37df4b59090e@linux-foundation.org> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 01/07/24 at 10:21am, Andrew Morton wrote: > 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? Yeah, this isn't like other warnings in kernel. The compiler seems too smart by look into the parameter 'args' of 'struct warn_args*'. > > 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); > } >