Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5035089rwr; Sun, 30 Apr 2023 21:49:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4b2wxAOIkaV13VnWHLDbPZm8aMCw28wBju7QHih3WmxpvvYXE4oNr71pUoARtxPN48l3fA X-Received: by 2002:a05:6a20:a29f:b0:f3:6406:9b0e with SMTP id a31-20020a056a20a29f00b000f364069b0emr11473287pzl.23.1682916569183; Sun, 30 Apr 2023 21:49:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682916569; cv=none; d=google.com; s=arc-20160816; b=dHzvyhOfDP0xvKo1RumOEni5fV1xcUzGrQYShKNsdqRkkcu2PA++NKrtSLwBThX3IY mIqDv3VDOxj4khzDE7n7F/LCOsiJoQxxS9p3j1qGXUG1oKeyxFtFdrIOCaeq/3OTxAL+ ue/PC8QR5Ni/cKMDC7wHm+/WUcyIIuVR1UXzPbMBL1/O4UC9jTNteqDyLLHOd8Le5D5N uLkDjkzR+QV8gArtMKcprcglDOyIknVmMbKfyni3aYx9cnO7CX/arH/OiGl9nwjDkNUJ ofkvTBwcinr5jlO5YduxLw8g7w/b5bTBsZFsBqF2QPx/WKKmWRwlmvea1B+oGt/p6oy4 UG9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ko4tiDMCNwPwiBKs4VgPoNPtRXixXezyuAJ9a6xO9RM=; b=xWYVcBb+t4a3Bg5cmAq71hMOwHWAX7pCdy0+PqkVCjMnfY9GvgZlYbcVBNcbAR5D4V Sq6hcSCjIEDI2POl7hppdvPnGxwbhPQ1qIl5NKJbwNpFU6wqzO0TdMZs70C+0d+ksjXJ WvVTydcZCy72oAWlmdVs8d9kpZAU4iicdHwDMXB1L5op79t6z51bIIU56dYRvyyGHUCk rB3I/f11Q8ANQIHCfolJ3WXGxOnXHhuvbVIjsb4KRE9U5NR9oiZzqBhGP/94yjc8KpUu XEGCXHb3ANs2RGWOXr9lO4uNXhXg7xZ7VhHFCMASNigYUk/UWaTAf2K2A+vVEe/B5QWO vYnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=FtSp4b+A; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020aa79f10000000b0063b82909b1esi26530650pfr.0.2023.04.30.21.49.15; Sun, 30 Apr 2023 21:49:29 -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=@gmail.com header.s=20221208 header.b=FtSp4b+A; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232041AbjEAEiO (ORCPT + 99 others); Mon, 1 May 2023 00:38:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229909AbjEAEiM (ORCPT ); Mon, 1 May 2023 00:38:12 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33D0510C4 for ; Sun, 30 Apr 2023 21:38:10 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-24b725d6898so1266537a91.2 for ; Sun, 30 Apr 2023 21:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682915889; x=1685507889; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ko4tiDMCNwPwiBKs4VgPoNPtRXixXezyuAJ9a6xO9RM=; b=FtSp4b+ASDxukXFtW2S7EkatC+DYXYpzImjp1YBuwCY5wswC5emZTsjs9WDEFMARfB 9nKF8Afp94nX3y3OAO+ACNRNI8nXe5j01y8jD3J/8xUsVs1glZ80zpk2amST3EHiLgbq evVBRoBiWSsRUNeDVZUlZmx5Pnb8zJLcQ9QJG+rmPRz2KXBqHkRUTVcYdeV3EZQkuch9 qq0a0HZUvawATjPDroD7u3UYV8vkBj5WDOq6pq8FjrOowGnsXt9tNFsyzh1/PbcZ1IyK 8eJoOuxFow9/OvH9KGnLIoRrjWqYz3ivaIg2p450nK7TW1cwXSBrXMUB3BmBDhDTqykp wjjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682915889; x=1685507889; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ko4tiDMCNwPwiBKs4VgPoNPtRXixXezyuAJ9a6xO9RM=; b=mEHaGMCdZqBJ1MZBGfjSLI/piRedcFZsVvDSvrkqd2QCapatt+EKL4PDmmAbfT+x82 xkxRcn1Vp3VOs2ehed6W2GGGIoNx0KS5GtpVkauL0GeQDUOmUr52y8OT7WUcOaBLYujL vIhZ2NIRI/jpquIGbTk8adAENVq9Wb5Kp2GTJp8rr1Bi3ecQPDQ72U7T0dAMkbxs6oQO ZxdT3g9fu/7qDkDJvIWK6nUSzVfPodrJ9qFlNSpCqxpbJH7QjbdfTzt5Vgq1+YkvX5qS 93gx4AKPfIcolLlxNtqizaYyjFs4SbJRDeyV+5NIA4YqRebjeYpeifPSiQZmLKURcmLn jkqw== X-Gm-Message-State: AC+VfDz0m1J2zoK1rW9QR/TzG58Jbtlk2HVTGgzPMnaH2sk5//Vbnjdv +UXTkuMVFKni46IJZM3McNykLK7NYmPsnc7zbLw= X-Received: by 2002:a17:902:fa46:b0:1a6:a327:67e1 with SMTP id lb6-20020a170902fa4600b001a6a32767e1mr12725886plb.57.1682915889531; Sun, 30 Apr 2023 21:38:09 -0700 (PDT) MIME-Version: 1.0 References: <20230429044506.24843-1-rdunlap@infradead.org> In-Reply-To: <20230429044506.24843-1-rdunlap@infradead.org> From: Lai Jiangshan Date: Mon, 1 May 2023 12:37:57 +0800 Message-ID: Subject: Re: [RFC PATCH] workqueue: fix cast warnings on i386 To: Randy Dunlap Cc: linux-kernel@vger.kernel.org, Tejun Heo Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 29, 2023 at 12:45=E2=80=AFPM Randy Dunlap wrote: > > Add casts to avoid int-to-pointer-cast warings on i386 or UML for i386: > > ../kernel/workqueue.c: In function =E2=80=98get_work_pwq=E2=80=99: > ../kernel/workqueue.c:713:24: warning: cast to pointer from integer of di= fferent size [-Wint-to-pointer-cast] > 713 | return (void *)(data & WORK_STRUCT_WQ_DATA_MASK); > | ^ > ../kernel/workqueue.c: In function =E2=80=98get_work_pool=E2=80=99: > ../kernel/workqueue.c:741:25: warning: cast to pointer from integer of di= fferent size [-Wint-to-pointer-cast] > 741 | return ((struct pool_workqueue *) > | ^ > ../kernel/workqueue.c: In function =E2=80=98get_work_pool_id=E2=80=99: > ../kernel/workqueue.c:763:25: warning: cast to pointer from integer of di= fferent size [-Wint-to-pointer-cast] > 763 | return ((struct pool_workqueue *) > | ^ > Hello, Randy Both the type of the "data" and WORK_STRUCT_WQ_DATA_MASK are "unsigned long", so I don't think "(data & WORK_STRUCT_WQ_DATA_MASK)" needs to be converted to "unsigned long". WORK_STRUCT_FLAG_MASK =3D (1UL << WORK_STRUCT_FLAG_BITS) - 1, WORK_STRUCT_WQ_DATA_MASK =3D ~WORK_STRUCT_FLAG_MASK, This simple fix might hide the real problem. Thanks Lai. > Fixes: e120153ddf86 ("workqueue: fix how cpu number is stored in work->da= ta") > Fixes: 112202d9098a ("workqueue: rename cpu_workqueue to pool_workqueue") > Signed-off-by: Randy Dunlap > Cc: Tejun Heo > Cc: Lai Jiangshan > --- > kernel/workqueue.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff -- a/kernel/workqueue.c b/kernel/workqueue.c > --- a/kernel/workqueue.c > +++ b/kernel/workqueue.c > @@ -710,7 +710,7 @@ static struct pool_workqueue *get_work_p > unsigned long data =3D atomic_long_read(&work->data); > > if (data & WORK_STRUCT_PWQ) > - return (void *)(data & WORK_STRUCT_WQ_DATA_MASK); > + return (void *)(unsigned long)(data & WORK_STRUCT_WQ_DATA= _MASK); > else > return NULL; > } > @@ -739,7 +739,7 @@ static struct worker_pool *get_work_pool > > if (data & WORK_STRUCT_PWQ) > return ((struct pool_workqueue *) > - (data & WORK_STRUCT_WQ_DATA_MASK))->pool; > + (unsigned long)(data & WORK_STRUCT_WQ_DATA_MASK))= ->pool; > > pool_id =3D data >> WORK_OFFQ_POOL_SHIFT; > if (pool_id =3D=3D WORK_OFFQ_POOL_NONE) > @@ -761,7 +761,7 @@ static int get_work_pool_id(struct work_ > > if (data & WORK_STRUCT_PWQ) > return ((struct pool_workqueue *) > - (data & WORK_STRUCT_WQ_DATA_MASK))->pool->id; > + (unsigned long)(data & WORK_STRUCT_WQ_DATA_MASK))= ->pool->id; > > return data >> WORK_OFFQ_POOL_SHIFT; > }