Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp115378lqo; Tue, 7 May 2024 14:06:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXw/YxGX1panGMl7H+xXQS+VNVVvPBnCzr9mir8LTdFZKNc84Pd2BOL4Jt+Iw0ZxIvw0lZ/1rdrZe2NSer0A9r9Wh8/WL753vTgiBsKlg== X-Google-Smtp-Source: AGHT+IEsFwTsO/9XtGBR+dlHrmhIz0lLWIEGMOuH9Up0lWLiVsI9735OdIX1GTmiZ6Rt17Y1L/oM X-Received: by 2002:a05:620a:809:b0:78e:e46b:5b04 with SMTP id af79cd13be357-792b27df467mr92015985a.44.1715115967753; Tue, 07 May 2024 14:06:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715115967; cv=pass; d=google.com; s=arc-20160816; b=MX/0kRwkPw4DsFFu8ERfGXeuQZHRgkj8Wgsp89tjQbmVzLMUevL3hm1Dcc0DUkYnIN 31yk7FUYS5HFIlEoaA+xXzfPocZc+HPLHhBnsZ3oq3fGlextUbiO6N/HKH8Up9a5nDAX NtEm3NGskWvDS/sICM9zG/XtRD6FSulvkglskqQ7hg1+SIFD4dk6igX328sKq9yQRj4Z RDBDn31aGAYXI2pkrQi709ytzghkn7jQn1CzWdPSRBvLvQKuVA4Q/1RJ+GU8Z65w++nf uR0eh3uAcpJX61zw4uXsMQRdaWGcYjjYOQQmEOCxK65OQuqOShOKXL8ET5OD7yPXd8hM hEdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=2ef/OTw1FTNHv7I5hPzJjnHJ7ssdwk8G3HA7pFWiHOs=; fh=S8StD+ZfCTZ2k2Qjrz63ppPcPFoHISPUX/BikC/nojM=; b=1KS5hm5j4pqL6dkakBfMo8wUpvNOGbvbWFqrf25OkY2mw5grIxtWzr8Y+R4FlQz5VJ CXuG5v5r1yzyiMOVBLhOGb4391veidYnQGxsIoHTSx2JGxREHHLhvHnkANFU8KbmKDAD TVQzuf4hrvOjy8GYGS0F4lnmoDzRbmxGgBqAwduFK9tVcb31idhTLZE4o8NdIxqctmlr poVpKhuwuK2JVpY/UxvapnTtXf9KY+mddxIfTMIc6nkbl38Wdyr/ffVKaYxJxn0auzzM HUlRqVsdps2xbonejVAtgo7y4nZwcgCyxOiXfoqyHZcnxZDlLGO5JgmyMY+XWddEc7Vc LYNw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fkmyOVhS; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-172188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172188-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i18-20020a05620a405200b0078efe14d82esi13602117qko.309.2024.05.07.14.06.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 14:06:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fkmyOVhS; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-172188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172188-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7BA621C20C95 for ; Tue, 7 May 2024 21:06:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99F217317E; Tue, 7 May 2024 21:06:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fkmyOVhS" Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F2E8187353; Tue, 7 May 2024 21:05:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715115959; cv=none; b=XJCCbEzyphFQMWWh7Pny5VOAMEAS+xl7Xs6vA7fvN/tuJt5eACKANLjfHOGYtNwKvZpf1v96F46wY32LPtRgtuEJe3pN9JwhnL/A299nuBH8xQnZ4TYAyKuvtnqDB0zTaELnazZpgYqrRTe1Z9jXgn2cfmeGgq3y9fvqmkBhu3s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715115959; c=relaxed/simple; bh=eETH8qyLZaEqH0jAscPRS9ATGH9bfwR8HhG7OFw2pEw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=iULKKoCpSjARI6az3xDQCyoNUnQRPmUUQdUmzXvh99Q731yHE6KCWRBsyDCXprliBhPdL+8Ts2UnozBsdPrtKuiealLYxpF7rKOvqDCSCIsGCkb9hZ5wbAgfbgz2JCiTTZrKMhCuvCS7xI3q3JhaRuX2fhtkZwZoMAYLHq6JXQg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fkmyOVhS; arc=none smtp.client-ip=209.85.208.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2e22a1bed91so47999291fa.0; Tue, 07 May 2024 14:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715115956; x=1715720756; darn=vger.kernel.org; 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=2ef/OTw1FTNHv7I5hPzJjnHJ7ssdwk8G3HA7pFWiHOs=; b=fkmyOVhSpq30fxaVZF35CHYrIdhVf63/OzaOys7u8nGP/uva+8JtHlJqTMsK9xCg/A VJgFeltcOczLES/TQdJoZlhdDIn+eb05NV2XqmEpnAeDucPzoqE1FVMPRDyZvPWeW6W/ dt20Qfz8/nORVQSivqR9nEsYVyGzHkuUPTkgJwqXSTi5trS8TzaUyKn+xDQ2eOqf61SN 1Z1asqXbUpC5obCvrLVVxkP16JQdvALaIEPRK0OIdJZTcQi9ocb2oxZ913F5TVDF2DT5 7TDvM2evGc0QCKUKvK5nJhJr71srsg5N8GUIITxXI9UpSRMc/UvV8etwXfQE48LB797A 5XWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715115956; x=1715720756; 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=2ef/OTw1FTNHv7I5hPzJjnHJ7ssdwk8G3HA7pFWiHOs=; b=r2OWQIm7bCy3LOF+KxyXNZPCdXNcYOhUheQogYyClUvQYK6T0QifwrgrAm6mdjFQpb +ZPHSr+FC+bysW8BK1ltwp3UzWwEJJc2+r8iu9QPmFT43EmlFqWjpjPMyunsU4GvlsOp TF9bBETXCgxDrSMfNtYt2M7E+1V6H9jsBAWlStybwT6eukgyJVUyxKrzUDe5IpppzYLz bFqVadozXk5mCoP6H9MWJ0Qdo48mjF9GPFWBJDZVvuOQuLw6eeeODeypL323zR7gz88a z44KJ0eYfFMKF4ECdxYsM4bqgO2q53bAS7E9ytQqKPVccsgXTCpeFrYD+15kVX+1bgVP xdEg== X-Forwarded-Encrypted: i=1; AJvYcCUZ4gAN6kSnJFA8uJ0UTnhNiDCmymG3XPKFEDnCWbxytMwP5Fq2bCD/rhMriSNgP6XKyW5RIdp+XaKezif/Vv9qg2A4NjkUR6u0q9eedb+E8s4sTCM0E1HvSW90zbIeHskkwKph/XaaE+E= X-Gm-Message-State: AOJu0YwF18jv86VGjSbcQQGjJsp4ZGNO7CmGeGL88TmfjMewxcYa70PL FEi+dyHQfplDc/UdTzuVOS6k5OJzey/RcBcElSmYwftznBEHOIab773Cde4sOCCwWyXkYn0KO67 HDarWHBhZApSbySWVi7eKN6eL1wY= X-Received: by 2002:ac2:520b:0:b0:51d:4472:c3f8 with SMTP id 2adb3069b0e04-5217c667418mr362253e87.35.1715115955829; Tue, 07 May 2024 14:05:55 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240507142454.3344-1-konishi.ryusuke@gmail.com> In-Reply-To: From: Ryusuke Konishi Date: Wed, 8 May 2024 06:05:39 +0900 Message-ID: Subject: Re: [PATCH -mm] nilfs2: Use __field_struct() for a bitwise field To: Linus Torvalds Cc: Andrew Morton , Bart Van Assche , linux-nilfs@vger.kernel.org, linux-kernel@vger.kernel.org, Rasmus Villemoes Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 8, 2024 at 1:25=E2=80=AFAM Linus Torvalds wrote: > > On Tue, 7 May 2024 at 07:25, Ryusuke Konishi = wrote: > > > > Despite that change, sparse complains when > > passing a bitwise type to is_signed_type(). It is not clear to me why. > > Bah. The reason is this: > > #define is_signed_type(type) (((type)(-1)) < (__force type)1) > > Basically, the way "is_signed_type()" works is that it casts a > negative integer to the type, and checks to see if the value has now > become a large value. > > Now, it looks odd, because only one of those casts has a "__force" on > it, but the reason for that is that casting all-ones and all-zeroes is > ok for bitwise types (think of bitwise types as being a "collection of > bits" - so all bits set or all bits clear are sane concepts regardless > of any other semantics). > > So it's not the casts themselves that are problematic: that part works fi= ne. > > But you cannot compare a random collection of bits for greater than or > lesser than. > > Think of things like byte orders: you can compare two values for > _equality_ even if they are in the wrong byte order, but you can't > compare them for "larger than" unless you turn them into the right CPU > byte order. > > Basically, a "collection of bits" doesn't have an ordering in itself, > even if equality comparisons are ok. > > So yeah, is_signed_type() doesn't work for bitwise types. > > And I don't see a sane way to make "is_signed_type()" to work for > bitwise types - the whole concept of signedness of "bunch of bits" is > kind of nonsensical - so I suspect your workaround is the best we can > do (alternatively, tracing would have to figure out a different way to > test for signedness). > > Linus Linus, thank you very much for your detailed explanation. I would like to edit the quoted part of his commit message > > Despite that change, sparse complains when > > passing a bitwise type to is_signed_type(). It is not clear to me why. as follows: Despite that change, sparse complains when passing a bitwise type to is_signed_type(). The reason is that in its definition below, a comparison will be made against bitwise types, which are random collections of bits (the casts to bitwise types themselves are semantically valid and are not problematic): #define is_signed_type(type) (((type)(-1)) < (__force type)1) So, as a workaround, fix the warnings by using __field_struct() macro that doesn't use is_signed_type() instead of __field(). ... I will try to resend the patch later unless there's a misunderstanding or I'm missing too many points. Thanks, Ryusuke Konishi