Message ID | 20230429044506.24843-1-rdunlap@infradead.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1397493vqo; Fri, 28 Apr 2023 22:25:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7h39X0WSTykrM0319n2aTQvRLEhM9xbDmazQD80F/b1O4yv4Em1joLi1EkrIsx5OjY4gXl X-Received: by 2002:a05:6a20:441b:b0:f2:4c39:8028 with SMTP id ce27-20020a056a20441b00b000f24c398028mr9868853pzb.21.1682745906668; Fri, 28 Apr 2023 22:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682745906; cv=none; d=google.com; s=arc-20160816; b=qgze3nf0G2F++HQfpkXQ+XZ9BVcAJ8DYxOqMkg2aE9WrphoYtV8A1ozFesLDd/ZjkQ MfJQJXM2868j6gkn4qk2dh/pEJ227AHLc/79QhPf+j10Vmw4gc0F/k2ArYs2KMzeOXh4 aGu3LtfKoAnCfbMxLgF4/IKV1JeXD/LoQMaZfJEhJBL0Vi7eXcAUDmU4h28iyc7Oyn4Y ex57+0YVDPslR1mfDNEybfkWA7HChCUdcifXu7cQWT2b8GdxHYV8uW51w1l53iYnS527 LL2dH2rUTosD2tXcgLub1gAjgXwKBhm0fmXpDTvxL2XRwmvRTDRIYxqXwB17Dps+IhWN lKiQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=3MmkiiZNk9+wb8Klw3jzPi8fh73m62AVfCNe2hPNLUU=; b=RwpuAbAyE9Q0CTVe/xN03eRMVHt0xQhnGOeomS/lxps6ni+0s83O2n4K+Nc9wUe2xo OZGAAHLlptJ0vpczL7jf7YU+DzlJza4uGQqlLLQAUFAjO7B1bnVlBDtQPe/4g3RRi6rK OvX5dHGJsJnDcacCGwCzjsQSbIpjld4AFbQKt99tpoS/8sOL6+hZoMbg7O8L4FCNSkHg yRQjoPCvdfkUpq/tgx53sxAiPATdmFtu/27bbioqZvKIdeHdnu71SeSyy5QeMbGzycSD L3B+rzqBkhi0LOkyvlL69eqsFlei4vtDkGu2rAyZTVvxkI7Zq9Q9dB7UmjdrAqhE9U2k TwMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=3OCkz1Yg; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a6540cb000000b0051b25fd77absi21430038pgp.887.2023.04.28.22.24.51; Fri, 28 Apr 2023 22:25:06 -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=@infradead.org header.s=bombadil.20210309 header.b=3OCkz1Yg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229918AbjD2EpN (ORCPT <rfc822;chrisjones.unixmen@gmail.com> + 99 others); Sat, 29 Apr 2023 00:45:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347214AbjD2EpK (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 29 Apr 2023 00:45:10 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D046B2D7F for <linux-kernel@vger.kernel.org>; Fri, 28 Apr 2023 21:45:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:In-Reply-To:References; bh=3MmkiiZNk9+wb8Klw3jzPi8fh73m62AVfCNe2hPNLUU=; b=3OCkz1YgKtsppB85cXDdCi2F3q fQUvS0lN1/beLdci4WMpPWxc5l1L68XpvPJN5Fy11nojc16aVxNsy2lEhnKQoBuKfxYfHqQOZtlpD nEC9+DbaV+/oNNRL7P2kzCfAxKFgGEJO88aoFwioU4df6F63Jn346rm7U2Zjyts/b4gCrsT75DNNP 4PGve5JHfmgWC5UJxzQj0RxqMUMwW2xF2trmEuLCD1GMZ2ELuqxGwA3M4Mla9Clld4OxL/2jgEL+O SVvPBAhHZnjljqh7BK27Nf+GEv7246ivJ5HjCgr4HkhN/wfdpDz9Zao2RPwWf3QHk37ko+6qoGzQy fzX4g7MA==; Received: from [2601:1c2:980:9ec0::2764] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1pscSJ-00CEcL-1M; Sat, 29 Apr 2023 04:45:08 +0000 From: Randy Dunlap <rdunlap@infradead.org> To: linux-kernel@vger.kernel.org Cc: Randy Dunlap <rdunlap@infradead.org>, Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com> Subject: [RFC PATCH] workqueue: fix cast warnings on i386 Date: Fri, 28 Apr 2023 21:45:06 -0700 Message-Id: <20230429044506.24843-1-rdunlap@infradead.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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_NONE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764486971828158617?= X-GMAIL-MSGID: =?utf-8?q?1764486971828158617?= |
Series |
[RFC] workqueue: fix cast warnings on i386
|
|
Commit Message
Randy Dunlap
April 29, 2023, 4:45 a.m. UTC
Add casts to avoid int-to-pointer-cast warings on i386 or UML for i386:
../kernel/workqueue.c: In function ‘get_work_pwq’:
../kernel/workqueue.c:713:24: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
713 | return (void *)(data & WORK_STRUCT_WQ_DATA_MASK);
| ^
../kernel/workqueue.c: In function ‘get_work_pool’:
../kernel/workqueue.c:741:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
741 | return ((struct pool_workqueue *)
| ^
../kernel/workqueue.c: In function ‘get_work_pool_id’:
../kernel/workqueue.c:763:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
763 | return ((struct pool_workqueue *)
| ^
Fixes: e120153ddf86 ("workqueue: fix how cpu number is stored in work->data")
Fixes: 112202d9098a ("workqueue: rename cpu_workqueue to pool_workqueue")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
---
kernel/workqueue.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On Sat, Apr 29, 2023 at 12:45 PM Randy Dunlap <rdunlap@infradead.org> wrote: > > Add casts to avoid int-to-pointer-cast warings on i386 or UML for i386: > > ../kernel/workqueue.c: In function ‘get_work_pwq’: > ../kernel/workqueue.c:713:24: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] > 713 | return (void *)(data & WORK_STRUCT_WQ_DATA_MASK); > | ^ > ../kernel/workqueue.c: In function ‘get_work_pool’: > ../kernel/workqueue.c:741:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] > 741 | return ((struct pool_workqueue *) > | ^ > ../kernel/workqueue.c: In function ‘get_work_pool_id’: > ../kernel/workqueue.c:763:25: warning: cast to pointer from integer of different 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 = (1UL << WORK_STRUCT_FLAG_BITS) - 1, WORK_STRUCT_WQ_DATA_MASK = ~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->data") > Fixes: 112202d9098a ("workqueue: rename cpu_workqueue to pool_workqueue") > Signed-off-by: Randy Dunlap <rdunlap@infradead.org> > Cc: Tejun Heo <tj@kernel.org> > Cc: Lai Jiangshan <jiangshanlai@gmail.com> > --- > 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 = 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 = data >> WORK_OFFQ_POOL_SHIFT; > if (pool_id == 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; > }
Hi Lai, On 4/30/23 21:37, Lai Jiangshan wrote: > On Sat, Apr 29, 2023 at 12:45 PM Randy Dunlap <rdunlap@infradead.org> wrote: >> >> Add casts to avoid int-to-pointer-cast warings on i386 or UML for i386: >> >> ../kernel/workqueue.c: In function ‘get_work_pwq’: >> ../kernel/workqueue.c:713:24: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] >> 713 | return (void *)(data & WORK_STRUCT_WQ_DATA_MASK); >> | ^ >> ../kernel/workqueue.c: In function ‘get_work_pool’: >> ../kernel/workqueue.c:741:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] >> 741 | return ((struct pool_workqueue *) >> | ^ >> ../kernel/workqueue.c: In function ‘get_work_pool_id’: >> ../kernel/workqueue.c:763:25: warning: cast to pointer from integer of different 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 = (1UL << WORK_STRUCT_FLAG_BITS) - 1, > WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK, > > This simple fix might hide the real problem. Thanks for replying. Do you have any suggestions for how to eliminate these warnings on i386 and ARCH=um SUBARCH=i386? > Thanks > Lai. > >> Fixes: e120153ddf86 ("workqueue: fix how cpu number is stored in work->data") >> Fixes: 112202d9098a ("workqueue: rename cpu_workqueue to pool_workqueue") >> Signed-off-by: Randy Dunlap <rdunlap@infradead.org> >> Cc: Tejun Heo <tj@kernel.org> >> Cc: Lai Jiangshan <jiangshanlai@gmail.com> >> --- >> 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 = 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 = data >> WORK_OFFQ_POOL_SHIFT; >> if (pool_id == 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; >> }
On Mon, May 1, 2023, at 06:42, Randy Dunlap wrote: > On 4/30/23 21:37, Lai Jiangshan wrote: >> 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 = (1UL << WORK_STRUCT_FLAG_BITS) - 1, >> WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK, >> >> This simple fix might hide the real problem. > > Thanks for replying. > > Do you have any suggestions for how to eliminate these warnings on i386 > and ARCH=um SUBARCH=i386? I'm pretty sure the patch I posted earlier is the correct one, see https://lore.kernel.org/all/20230117164041.1207412-1-arnd@kernel.org/ Sorry I never followed up on this after the initial post, I have a backlog of patches that I sent out as build fixes but that for some reason have not made it in. Arnd
On 5/8/23 06:41, Arnd Bergmann wrote: > On Mon, May 1, 2023, at 06:42, Randy Dunlap wrote: >> On 4/30/23 21:37, Lai Jiangshan wrote: >>> 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 = (1UL << WORK_STRUCT_FLAG_BITS) - 1, >>> WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK, >>> >>> This simple fix might hide the real problem. >> >> Thanks for replying. >> >> Do you have any suggestions for how to eliminate these warnings on i386 >> and ARCH=um SUBARCH=i386? > > I'm pretty sure the patch I posted earlier is the correct one, see > https://lore.kernel.org/all/20230117164041.1207412-1-arnd@kernel.org/ > Thanks for the reply. Your patch looks good. I appreciate the explanation. > Sorry I never followed up on this after the initial post, I have > a backlog of patches that I sent out as build fixes but that for > some reason have not made it in. I know how that goes. I have quite a few as well.
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 = 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 = data >> WORK_OFFQ_POOL_SHIFT; if (pool_id == 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; }