Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3755684pxf; Mon, 22 Mar 2021 14:20:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxiUX+2fnpoKduOvOLH3bAOuw8ReY3gcXQtO4YT42RUIPyh12IBnIQPjQ9VDjjNPWZy7iW X-Received: by 2002:a05:6402:b41:: with SMTP id bx1mr1571165edb.69.1616448025479; Mon, 22 Mar 2021 14:20:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616448025; cv=none; d=google.com; s=arc-20160816; b=nPWnu5WNYDko3XlxAekpCUjzcIEhP9UFaabrnOMzdUxSjBWSdQlAd8Pgv98oEhOekx 8QZkVl8yOlPSTI+9lGPefypcKGGXwFfMr8mvHtxF0KqRJ0ElJ8SNSM1/HsHL4Eo+7Dwx PAx2KpRWj8VdETKhQ2TWSlG19VxRLso1VH7hZ12Nzd8vFS1rUiD3XdssgXBXdZ0E8Za9 nd9ybkRk5/T23OBk0z2688NUsmTD7aFUcIo4tJFZOYk7PMMq0gxmKmGVcrZGy4HbvZ1a nIiwf96C717Td94ZM8KziAdKDzc5Md/5ReNvIn4b8Ofu88WY2XOHgqk8QEjcJsiA04WB FwFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ULQGcvHOjwS9OUaWYFsmYMjIAcK4lCTG2tr6Fsm0dUU=; b=DZunyZpB+rlsntVbTdvMda2ePNUqx7QcOHDQxwlZN3ugWvTSVEVf6SUcXem0W5rGJN /vbEsRB+y8OmQahCVmuT519Gerx1ZZ37qv1job6Ib8HuSgBP4frQE++49gBIaCoOFa9b rKO4B+7V+/wp5759EkXnukbW8GBo5vEUQgBjeK1iA9FaE7kaJxzOBKmYbVojESwUSZQj BThjlfAxRh9EwPFqvx32PSKqHcAVsFm2bjBGWoaReD8h9NfLHKa/QZq6AjVsoKJ8++PT CsT5r/qq4KffQtVEnraVv1xneEmlAtta7d7NzBMfV1AKFuIggTFbEcjZ+hIdrJ2oA2/Q gIog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n32+ueZW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v14si12036164ejj.133.2021.03.22.14.19.54; Mon, 22 Mar 2021 14:20:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n32+ueZW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229955AbhCVVSk (ORCPT + 99 others); Mon, 22 Mar 2021 17:18:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:42594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbhCVVSf (ORCPT ); Mon, 22 Mar 2021 17:18:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 76669619A3 for ; Mon, 22 Mar 2021 21:18:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616447914; bh=3oLBjoNBWt0NssVyfXaYTa63nu5lkspGWQiFfkqWL1s=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=n32+ueZW/UW2ffH44egSG6VCgOv8vyhK50R/c57UiBsPtEm6JceDn0VKZdgjKc4LA 7Oyu2iUdkqinuXGxK48KW8pEiB9n40LLi+x4TXIbSR6JJQbx++oGFHDmUqjPVH/Q2c S1Q1dW+Sl1YARPO5JNQue2BN3SihClOabGo61WRF3/B0K8G6jbVUW5s4brWphPghzg FCi2XUbPl73pF1LWRhFYzAO0j5JZdgBPnhJxtbr1iugVqq1+Xa6Ke1R2iJvMdLS8Xq CetDfJ0yNGVnOoIIF/WXGnfiJXgEB8rWEUScGOYtt74F49uQjZYpbOC9YnBdAh9tts mX9k1VgYdvFhg== Received: by mail-oi1-f175.google.com with SMTP id x2so14636094oiv.2 for ; Mon, 22 Mar 2021 14:18:34 -0700 (PDT) X-Gm-Message-State: AOAM533IRA9y5gr0TtaDrCmxO62DpOtCC9omxrn+d/CmZoWly2HwgJTx yCpv855CK5s456gB2NvKJkYDmIFKtcmWohopbNc= X-Received: by 2002:a05:6808:3d9:: with SMTP id o25mr814700oie.4.1616447913693; Mon, 22 Mar 2021 14:18:33 -0700 (PDT) MIME-Version: 1.0 References: <20210322170711.1855115-1-arnd@kernel.org> <20210322153214.25d869b1@gandalf.local.home> In-Reply-To: From: Arnd Bergmann Date: Mon, 22 Mar 2021 22:18:17 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] static_call: fix function type mismatch To: Peter Zijlstra Cc: Steven Rostedt , Josh Poimboeuf , Jason Baron , Ingo Molnar , Juri Lelli , Vincent Guittot , Ard Biesheuvel , Dietmar Eggemann , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Frederic Weisbecker , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 22, 2021 at 9:47 PM Peter Zijlstra wrote: > On Mon, Mar 22, 2021 at 03:32:14PM -0400, Steven Rostedt wrote: > > On Mon, 22 Mar 2021 18:06:37 +0100 > > Arnd Bergmann wrote: > > > > > From: Arnd Bergmann > > > > > > The __static_call_return0() function is declared to return a 'long', > > > while it aliases a couple of functions that all return 'int'. When > > > building with 'make W=1', gcc warns about this: > > > > > > kernel/sched/core.c:5420:37: error: cast between incompatible function types from 'long int (*)(void)' to 'int (*)(void)' [-Werror=cast-function-type] > > > 5420 | static_call_update(might_resched, (typeof(&__cond_resched)) __static_call_return0); > > > > > > Change the function to return 'int' as well, but remove the cast to > > > ensure we get a warning if any of the types ever change. > > > > I think the answer is the other way around. That is, to make the functions > > it references return long instead. __static_call_return0 is part of the > > dynamic call infrastructure. Perhaps it is currently only used by functions > > that return int, but what happens when it is used for a function that > > returns a pointer? I've done a little testing on the replacement patch now, will send in a bit. > Steve is correct. Also, why is that warning correct? On x86 we return in > RAX, and using int will simply not inspect the upper 32 bits there. I think the code works correctly on all architectures we support because both 'int' and 'long' are returned in a register with any unused bits cleared. It is however undefined behavior in C because 'int' and 'long' are not compatible types, and the calling conventions don't have to allow this. > And I'm fairly sure I had a pointer user somewhere recently. I've only tested my series with 5.12-rc so far, but don't get any other such warnings. Maybe it's in linux-next? Arnd