Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1770216ybv; Fri, 14 Feb 2020 05:46:43 -0800 (PST) X-Google-Smtp-Source: APXvYqy6+toxKrNtJqQwH+uAyCCLEqCNPaaAqUwhZ3sOCFzO3gLZK8yIjDvaeUP3mFSAeBbd7VuU X-Received: by 2002:a05:6830:1094:: with SMTP id y20mr2329250oto.12.1581688003435; Fri, 14 Feb 2020 05:46:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581688003; cv=none; d=google.com; s=arc-20160816; b=x+F4P7zcotebV57msFsPE77uek9e9s/k/BbK9idpJfP72PLLxAMZ4+BjU3qgV9hRit PykI2aOvFQ2nS4OecSxqLiGUZnIxzedNDqwEm+d2rFkO0OfEr9kWoVca4sONKwI28lHz dtcMA5YZjHDv399Qvk1nuhtyzVPcIKYXjS5d4Q9PHASpK4U/5oyhfJ3E5yjkG4+E1G0f JOrgHd3vIKWVAnHFIN620B5DrfcC+ENqo2umJifOCfrkI020z5kdm1teV7y1MW5Y+bgA pmmZtOVb9DfB9wK8hQfj43z4vaafGf8qS9tMtADYgrYujr1azZv/mM0in7kB1TZJOr2v XwAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Z2AWHyN/sOb4PsOQdZpFIB/8+XI9oSRqPBfKZfRwFiU=; b=dUUYh4YMVmuGG3hflc+xCdmKyZzDwS9uv55DmXuGtXedoGkqbhfOtMV2R6Bao1FJOo 9gONZ9gRhiNUZbgbGAQrBp7q45Gm8iP7YuhTs/svi0p+2mxUG8sEWaYmQbTfNupQ3equ DM5K333vMn0/aAY5afKGzAYtjlsBK1fdWCWB01COzgTJki0KnhkjND/bTCSIAlbtYfS1 HKJk92t1qOqRuShlocB3G4RvUNnSPbMuEWsgF7YaC+CEKanMRQ4fJ98vPSvHR8gH8wrG 2UpGVDOpBc28tEYo72preTEdczVjRtlCZxQ9k9YqUTPC1I5I4v/Ruh3uRnS4ezmK7WOQ SBmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Cvlk7S2k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q6si2834003oth.26.2020.02.14.05.46.31; Fri, 14 Feb 2020 05:46:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Cvlk7S2k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728452AbgBNNqR (ORCPT + 99 others); Fri, 14 Feb 2020 08:46:17 -0500 Received: from mail-oi1-f196.google.com ([209.85.167.196]:36049 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728121AbgBNNqR (ORCPT ); Fri, 14 Feb 2020 08:46:17 -0500 Received: by mail-oi1-f196.google.com with SMTP id c16so9452528oic.3 for ; Fri, 14 Feb 2020 05:46:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=Z2AWHyN/sOb4PsOQdZpFIB/8+XI9oSRqPBfKZfRwFiU=; b=Cvlk7S2k5FNnFaMpydJh39pH3ElahgOrWipX78FuTVFaxf29cfR+obZPVLb1Fn5iqH uDLkhVA0jBDmtwTB3X4MSEOHPBJcXLKCErV9jPgOcdyYFHYwQIOqAghL8TvYQvbMz+5+ +4TZBxiaF5pLh4ecvXXHacUTkln64pBdi1eQAmrGBrxDjg0xOAiGNyXvOFGcvmKG7PVr z/5Chh+c761a76kWqwUuerFL9V2FNYwZzYekwLn2pJQhUZr/E3Y+W7Ywdg6GW6YFdg66 K/YlabYQv5xVqBZYRlwXrSCgLVMw4IV5wqB0dFL5rO2FihwOIBIIJReYPygoq/8pckPK 9FMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=Z2AWHyN/sOb4PsOQdZpFIB/8+XI9oSRqPBfKZfRwFiU=; b=lq50tL/k+6fG6E6elXAGJNiQIi/vDGClim41r8hUt5RZ6hF1Ppsr7EzlJFcNMaAkgb 0yc2wn1r5SLqn4FlG5M7NQyJJtYhsjQ8JnPgFTMgAYOuONZ6NbeJCV3NCMuIvNuxM24a Wv7+MZeD4hF7a1dU0befXIiFiPLid09ugB/CnIxJOQn+jFgMG46ShdBd2Bh1o7w1Klc0 fEq2hUMvb2cKd3cMTJPuuzv2th6KqZvInK4Wqr8CHqbwskeishIkNf0CzRVeGsEIHROy K0BXc7tqxzFMfEM4yQZvu6uQy8PmfKZoLSJ0+RXBSoTEnCHRYFxLwwSc66ZEkqTbVqCS 3Lyg== X-Gm-Message-State: APjAAAXS3zCEP9dtMHKCIhIdcEwFox3yEE2sLHXvG3oN+7BmjcdFAcHa Q8seSSofEKQjURjKFdOmHTA= X-Received: by 2002:aca:4306:: with SMTP id q6mr1922461oia.54.1581687975994; Fri, 14 Feb 2020 05:46:15 -0800 (PST) Received: from ubuntu-m2-xlarge-x86 ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id k17sm1885677oic.45.2020.02.14.05.46.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Feb 2020 05:46:15 -0800 (PST) Date: Fri, 14 Feb 2020 06:46:13 -0700 From: Nathan Chancellor To: Chris Wilson Cc: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Michel =?iso-8859-1?Q?D=E4nzer?= Subject: Re: [PATCH] drm/i915: Cast remain to unsigned long in eb_relocate_vma Message-ID: <20200214134613.GA41838@ubuntu-m2-xlarge-x86> References: <20200214054706.33870-1-natechancellor@gmail.com> <87v9o965gg.fsf@intel.com> <158166913989.4660.10674824117292988120@skylake-alporthouse-com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <158166913989.4660.10674824117292988120@skylake-alporthouse-com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 14, 2020 at 08:32:19AM +0000, Chris Wilson wrote: > Quoting Jani Nikula (2020-02-14 06:36:15) > > On Thu, 13 Feb 2020, Nathan Chancellor wrote: > > > A recent commit in clang added -Wtautological-compare to -Wall, which is > > > enabled for i915 after -Wtautological-compare is disabled for the rest > > > of the kernel so we see the following warning on x86_64: > > > > > > ../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1433:22: warning: > > > result of comparison of constant 576460752303423487 with expression of > > > type 'unsigned int' is always false > > > [-Wtautological-constant-out-of-range-compare] > > > if (unlikely(remain > N_RELOC(ULONG_MAX))) > > > ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ > > > ../include/linux/compiler.h:78:42: note: expanded from macro 'unlikely' > > > # define unlikely(x) __builtin_expect(!!(x), 0) > > > ^ > > > 1 warning generated. > > > > > > It is not wrong in the case where ULONG_MAX > UINT_MAX but it does not > > > account for the case where this file is built for 32-bit x86, where > > > ULONG_MAX == UINT_MAX and this check is still relevant. > > > > > > Cast remain to unsigned long, which keeps the generated code the same > > > (verified with clang-11 on x86_64 and GCC 9.2.0 on x86 and x86_64) and > > > the warning is silenced so we can catch more potential issues in the > > > future. > > > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/778 > > > Suggested-by: Michel D?nzer > > > Signed-off-by: Nathan Chancellor > > > > Works for me as a workaround, > > But the whole point was that the compiler could see that it was > impossible and not emit the code. Doesn't this break that? > -Chris As noted in the commit message, I ran diff <(objdump -Dr) <(objdump -Dr) on objects files compiled with and without the patch with clang and gcc for x86_64 and gcc for i386 (i386 does not build with clang) and there was zero difference aside from the file names. At the end of the day, I do not really care how the warning get fixed, just that it does since it is the only one on x86_64 defconfig. Cheers, Nathan