Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4639878iob; Sun, 8 May 2022 20:13:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyh4Nz9QL6eMxgJ24Kr3XxHkafg4Os2fMBqDcPlYKfs5sCz3cciLOE3nx5eRrlFIwej+P3z X-Received: by 2002:a17:90b:1d0c:b0:1dd:220b:bac9 with SMTP id on12-20020a17090b1d0c00b001dd220bbac9mr1368087pjb.36.1652066037914; Sun, 08 May 2022 20:13:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652066037; cv=none; d=google.com; s=arc-20160816; b=lsLMS/Fdj7rIgg3PqUOc5JFYriRYaxmERY5lY3dmPBPN+QJfyBy2tlAefS6j7A1tVO LNIE7vIQ2be8Y/SVj73a95f3HVF1FuTVYQnyw/WCPVI5nvLByfh7H/d21Hi8D5i9hMw0 631v2p6PM7XHSTUjJik6ghyWB8Ire8+TBcKqBbsGtg6HZYb4YrU7ONsrlFU/4MpwUQKr 8y3rf7nFkgG57GTZRrHHTDVU++qBc9vBK2AjtYurGHkJWw5RROa4CNWIc6IZzs5VLxSI P83FF9/a5puPdheGcRSa4SvanYoRD1vaghKSaHqAtFRbKLVDVS6Q9zsCMO2nh7yYhH3N fd2A== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=+X6CMG/zk9HvYUTFzE6uYl9/ltv+Ky3+zfDXD1ch1IM=; b=EpvAfomJZKK4fZYFXlneEf2CPrgR/On8hKvO6oIF3est/jWSA+ONx7vEICmshQCx4e 2u9H5534KOY8Km7J1r7+usbNn0tVDAyPouh+4hyxl9cHNkYi08OaL9BfUVQRzaJQ/UEp Kas1G52+sQdiozd93yV8i6pEPzyPJn1Rygl+Atm/mozi5zO3zaLYScGhHnk80NI/+z6s Emh2fNm/qaE92BxiNV1sJrr2HurKpf0hvHRdnHrHz7E9PanPkTDxfAK8ZonyEmfLxo62 UFC6xPBuU39qQQ3KsRjTUNmSl7A083oNFRADZi1WtNOth0B4nQJpud3BxT70dFDvUlWt a5VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="b9DZcy/1"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id gj16-20020a17090b109000b001d2dc5fc896si16362802pjb.64.2022.05.08.20.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 20:13:57 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="b9DZcy/1"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BDD3D9135B; Sun, 8 May 2022 20:13:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446894AbiEGTlT (ORCPT + 99 others); Sat, 7 May 2022 15:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346517AbiEGTlT (ORCPT ); Sat, 7 May 2022 15:41:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1D2C20BE4 for ; Sat, 7 May 2022 12:37:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7DD8B60AD7 for ; Sat, 7 May 2022 19:37:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB96AC385A6; Sat, 7 May 2022 19:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1651952249; bh=Z6JKxRX6m7giLQ02yJaBTI+h0RfkKB7Q/x0qt4pglXU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=b9DZcy/1amKKer/ofiEFxALPCwm0fA9PfbzHqL49KN1UrMuUvnWY3crmhg51z5Jnc AZaB9qIAETkVPZboxuwcuxvBwesylhwvEsnQ4L6iYySa2bER9ILNndx9CQ+YYkFSmx e+zq5xKuovp+0guY941SJDDYTMTn5VT9X7F4QjeM= Date: Sat, 7 May 2022 12:37:28 -0700 From: Andrew Morton To: Vasily Averin Cc: Steven Rostedt , Ingo Molnar , kernel@openvz.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH mm] tracing: incorrect gfp_t conversion Message-Id: <20220507123728.f20d977eba9fbb66bddee722@linux-foundation.org> In-Reply-To: <331d88fe-f4f7-657c-02a2-d977f15fbff6@openvz.org> References: <331d88fe-f4f7-657c-02a2-d977f15fbff6@openvz.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE,UPPERCASE_50_75 autolearn=unavailable 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, 7 May 2022 22:02:05 +0300 Vasily Averin wrote: > Fixes the following sparse warnings: > > include/trace/events/*: sparse: cast to restricted gfp_t > include/trace/events/*: sparse: restricted gfp_t degrades to integer > > gfp_t type is bitwise and requires __force attributes for any casts. > > --- a/include/trace/events/mmflags.h > +++ b/include/trace/events/mmflags.h > @@ -14,43 +14,43 @@ > */ > > #define __def_gfpflag_names \ > - {(unsigned long)GFP_TRANSHUGE, "GFP_TRANSHUGE"}, \ > - {(unsigned long)GFP_TRANSHUGE_LIGHT, "GFP_TRANSHUGE_LIGHT"}, \ > - {(unsigned long)GFP_HIGHUSER_MOVABLE, "GFP_HIGHUSER_MOVABLE"},\ > - {(unsigned long)GFP_HIGHUSER, "GFP_HIGHUSER"}, \ > - {(unsigned long)GFP_USER, "GFP_USER"}, \ > - {(unsigned long)GFP_KERNEL_ACCOUNT, "GFP_KERNEL_ACCOUNT"}, \ > - {(unsigned long)__GFP_SKIP_KASAN_POISON,"__GFP_SKIP_KASAN_POISON"}\ > > ... > > + {(__force unsigned long)GFP_TRANSHUGE, "GFP_TRANSHUGE"}, \ > + {(__force unsigned long)GFP_TRANSHUGE_LIGHT, "GFP_TRANSHUGE_LIGHT"}, \ > + {(__force unsigned long)GFP_HIGHUSER_MOVABLE, "GFP_HIGHUSER_MOVABLE"},\ > + {(__force unsigned long)GFP_HIGHUSER, "GFP_HIGHUSER"}, \ > + {(__force unsigned long)GFP_USER, "GFP_USER"}, \ > + {(__force unsigned long)GFP_KERNEL_ACCOUNT, "GFP_KERNEL_ACCOUNT"}, \ > + {(__force unsigned long)GFP_KERNEL, "GFP_KERNEL"}, \ > + {(__force unsigned long)GFP_NOFS, "GFP_NOFS"}, \ This got all repetitive, line-wrappy and ugly :( What do we think of something silly like this? --- a/include/trace/events/mmflags.h~tracing-incorrect-gfp_t-conversion-fix +++ a/include/trace/events/mmflags.h @@ -13,53 +13,57 @@ * Thus most bits set go first. */ +#define FUL __force unsigned long + #define __def_gfpflag_names \ - {(__force unsigned long)GFP_TRANSHUGE, "GFP_TRANSHUGE"}, \ - {(__force unsigned long)GFP_TRANSHUGE_LIGHT, "GFP_TRANSHUGE_LIGHT"}, \ - {(__force unsigned long)GFP_HIGHUSER_MOVABLE, "GFP_HIGHUSER_MOVABLE"},\ - {(__force unsigned long)GFP_HIGHUSER, "GFP_HIGHUSER"}, \ - {(__force unsigned long)GFP_USER, "GFP_USER"}, \ - {(__force unsigned long)GFP_KERNEL_ACCOUNT, "GFP_KERNEL_ACCOUNT"}, \ - {(__force unsigned long)GFP_KERNEL, "GFP_KERNEL"}, \ - {(__force unsigned long)GFP_NOFS, "GFP_NOFS"}, \ - {(__force unsigned long)GFP_ATOMIC, "GFP_ATOMIC"}, \ - {(__force unsigned long)GFP_NOIO, "GFP_NOIO"}, \ - {(__force unsigned long)GFP_NOWAIT, "GFP_NOWAIT"}, \ - {(__force unsigned long)GFP_DMA, "GFP_DMA"}, \ - {(__force unsigned long)__GFP_HIGHMEM, "__GFP_HIGHMEM"}, \ - {(__force unsigned long)GFP_DMA32, "GFP_DMA32"}, \ - {(__force unsigned long)__GFP_HIGH, "__GFP_HIGH"}, \ - {(__force unsigned long)__GFP_ATOMIC, "__GFP_ATOMIC"}, \ - {(__force unsigned long)__GFP_IO, "__GFP_IO"}, \ - {(__force unsigned long)__GFP_FS, "__GFP_FS"}, \ - {(__force unsigned long)__GFP_NOWARN, "__GFP_NOWARN"}, \ - {(__force unsigned long)__GFP_RETRY_MAYFAIL, "__GFP_RETRY_MAYFAIL"}, \ - {(__force unsigned long)__GFP_NOFAIL, "__GFP_NOFAIL"}, \ - {(__force unsigned long)__GFP_NORETRY, "__GFP_NORETRY"}, \ - {(__force unsigned long)__GFP_COMP, "__GFP_COMP"}, \ - {(__force unsigned long)__GFP_ZERO, "__GFP_ZERO"}, \ - {(__force unsigned long)__GFP_NOMEMALLOC, "__GFP_NOMEMALLOC"}, \ - {(__force unsigned long)__GFP_MEMALLOC, "__GFP_MEMALLOC"}, \ - {(__force unsigned long)__GFP_HARDWALL, "__GFP_HARDWALL"}, \ - {(__force unsigned long)__GFP_THISNODE, "__GFP_THISNODE"}, \ - {(__force unsigned long)__GFP_RECLAIMABLE, "__GFP_RECLAIMABLE"}, \ - {(__force unsigned long)__GFP_MOVABLE, "__GFP_MOVABLE"}, \ - {(__force unsigned long)__GFP_ACCOUNT, "__GFP_ACCOUNT"}, \ - {(__force unsigned long)__GFP_WRITE, "__GFP_WRITE"}, \ - {(__force unsigned long)__GFP_RECLAIM, "__GFP_RECLAIM"}, \ - {(__force unsigned long)__GFP_DIRECT_RECLAIM, "__GFP_DIRECT_RECLAIM"},\ - {(__force unsigned long)__GFP_KSWAPD_RECLAIM, "__GFP_KSWAPD_RECLAIM"},\ - {(__force unsigned long)__GFP_ZEROTAGS, "__GFP_ZEROTAGS"} \ + {(FUL)GFP_TRANSHUGE, "GFP_TRANSHUGE"}, \ + {(FUL)GFP_TRANSHUGE_LIGHT, "GFP_TRANSHUGE_LIGHT"}, \ + {(FUL)GFP_HIGHUSER_MOVABLE, "GFP_HIGHUSER_MOVABLE"},\ + {(FUL)GFP_HIGHUSER, "GFP_HIGHUSER"}, \ + {(FUL)GFP_USER, "GFP_USER"}, \ + {(FUL)GFP_KERNEL_ACCOUNT, "GFP_KERNEL_ACCOUNT"}, \ + {(FUL)GFP_KERNEL, "GFP_KERNEL"}, \ + {(FUL)GFP_NOFS, "GFP_NOFS"}, \ + {(FUL)GFP_ATOMIC, "GFP_ATOMIC"}, \ + {(FUL)GFP_NOIO, "GFP_NOIO"}, \ + {(FUL)GFP_NOWAIT, "GFP_NOWAIT"}, \ + {(FUL)GFP_DMA, "GFP_DMA"}, \ + {(FUL)__GFP_HIGHMEM, "__GFP_HIGHMEM"}, \ + {(FUL)GFP_DMA32, "GFP_DMA32"}, \ + {(FUL)__GFP_HIGH, "__GFP_HIGH"}, \ + {(FUL)__GFP_ATOMIC, "__GFP_ATOMIC"}, \ + {(FUL)__GFP_IO, "__GFP_IO"}, \ + {(FUL)__GFP_FS, "__GFP_FS"}, \ + {(FUL)__GFP_NOWARN, "__GFP_NOWARN"}, \ + {(FUL)__GFP_RETRY_MAYFAIL, "__GFP_RETRY_MAYFAIL"}, \ + {(FUL)__GFP_NOFAIL, "__GFP_NOFAIL"}, \ + {(FUL)__GFP_NORETRY, "__GFP_NORETRY"}, \ + {(FUL)__GFP_COMP, "__GFP_COMP"}, \ + {(FUL)__GFP_ZERO, "__GFP_ZERO"}, \ + {(FUL)__GFP_NOMEMALLOC, "__GFP_NOMEMALLOC"}, \ + {(FUL)__GFP_MEMALLOC, "__GFP_MEMALLOC"}, \ + {(FUL)__GFP_HARDWALL, "__GFP_HARDWALL"}, \ + {(FUL)__GFP_THISNODE, "__GFP_THISNODE"}, \ + {(FUL)__GFP_RECLAIMABLE, "__GFP_RECLAIMABLE"}, \ + {(FUL)__GFP_MOVABLE, "__GFP_MOVABLE"}, \ + {(FUL)__GFP_ACCOUNT, "__GFP_ACCOUNT"}, \ + {(FUL)__GFP_WRITE, "__GFP_WRITE"}, \ + {(FUL)__GFP_RECLAIM, "__GFP_RECLAIM"}, \ + {(FUL)__GFP_DIRECT_RECLAIM, "__GFP_DIRECT_RECLAIM"},\ + {(FUL)__GFP_KSWAPD_RECLAIM, "__GFP_KSWAPD_RECLAIM"},\ + {(FUL)__GFP_ZEROTAGS, "__GFP_ZEROTAGS"} \ #ifdef CONFIG_KASAN_HW_TAGS #define __def_gfpflag_names_kasan , \ - {(__force unsigned long)__GFP_SKIP_ZERO, "__GFP_SKIP_ZERO"}, \ - {(__force unsigned long)__GFP_SKIP_KASAN_POISON, "__GFP_SKIP_KASAN_POISON"}, \ - {(__force unsigned long)__GFP_SKIP_KASAN_UNPOISON, "__GFP_SKIP_KASAN_UNPOISON"} + {(FUL)__GFP_SKIP_ZERO, "__GFP_SKIP_ZERO"}, \ + {(FUL)__GFP_SKIP_KASAN_POISON, "__GFP_SKIP_KASAN_POISON"}, \ + {(FUL)__GFP_SKIP_KASAN_UNPOISON, "__GFP_SKIP_KASAN_UNPOISON"} #else #define __def_gfpflag_names_kasan #endif +#undef FUL + #define show_gfp_flags(flags) \ (flags) ? __print_flags(flags, "|", \ __def_gfpflag_names __def_gfpflag_names_kasan \ _