Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2096623lqb; Mon, 27 May 2024 07:47:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXD5IgcH6MEfp3dD7C32KMtCM5SBWYiUVzF7NjklACf6SF630pwkfPaPH5y92R0CDeUgpZuVySo93xWUkDl7hmSXa2FJqcA5mW6vGPYvg== X-Google-Smtp-Source: AGHT+IETYjnCBztVe0DskUl5P6aB2VvXUKcvsp+fL77X8jl4kFW5k4auGxlkrwocTyOyFg5+JOgI X-Received: by 2002:a17:90a:fb8f:b0:2a0:2fb3:c1ff with SMTP id 98e67ed59e1d1-2bf5ee14909mr8276813a91.15.1716821228734; Mon, 27 May 2024 07:47:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716821228; cv=pass; d=google.com; s=arc-20160816; b=x2r4pH22ff+5H/mxZlP9npPNhUVlCR//ZPCbfnVkxo/VPnzXVaJPiTp6x8NzEZBlpE E1oygYKu63F+JqSqEMVHGz+H9ls/nnQgUDq79Kt2uS1hX3tqa6gXmylsbi3i6VimU46X gaFj5Aigf3Q2iEakv8hqTdVFpb56nyXqUTCYhQnEYkU+3RXfS96Y/i7EmOZkgewTsPAK eFoq7WXYOIy9Gkw/F+6rzdcMDN9b25aSPExzOUtipDpZnsru3ilRc+eqUoxhzbCfz2ez 7VrW8NaFlIhNC1hcD4p1/8zMXY8u+Z1oe6qynizFDZh49DjFvl3/9e4IgJ2tgilgx9Tj phuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:references :organization:in-reply-to:subject:cc:to:from:dkim-signature; bh=4UtXQo3ofJBI7gKNe3jXmWDYAACV4wEO5B4/zskWsds=; fh=zCKs/35Tkdt6Xx06d9liXWln0e1oNYS8g96AOoWF6tU=; b=Rh4FDW9RJZepaM35IbK+R26ttR9FaSCUmOAgKSgD/2JkSrtPmZJW97KYOVWKLbCQ1G SUlAqvG3FFZuHqvHndc0N8Rj75Jm5b5xLQKcc2xrtc26n12nqLwwIzhapQb38FHLFzQS yT4x+r2psvwbZ649/PNGuTwrSaPMNxUf/SB0SqOnJgDWu2YkxD1WtU33yEGx+us4z+S/ POzKDFj5U1QKHhE1plHnIxZIbs30/IgkhfK462krT7BvRcWWnBdsvq76Aw7HzF3bOsAx TP9KrAtn84az7mMUD9fXtFUtLwYdcT+8FTq8X2UbG2ODCYsY/xYmVmIw8RAuJ/i+HqUB gpMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ATKFYzzI; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-190797-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190797-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2bf5fe344ebsi6176279a91.120.2024.05.27.07.47.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 07:47:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190797-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ATKFYzzI; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-190797-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190797-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 34FDC299DF7 for ; Mon, 27 May 2024 14:09:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C26E15EFAE; Mon, 27 May 2024 14:06:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ATKFYzzI" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9ABB13A248 for ; Mon, 27 May 2024 14:06:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716818796; cv=none; b=ohH9opH86gd2G5uyxZ1M736XBrnXV0TXBX1dZPiY5FbRZCl41J05M5D6LqmOauDNuFYd0Yilyh+qOIF8bykaE78CinatRh4LIPxNIGHI6Ayxh9GXaVaP33Tsmdy+Ce9aDzSQ8dmYOd2S7N4XFe8POhQpIDMie0FTP9nScgvUH8s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716818796; c=relaxed/simple; bh=esIMTSoe6zhhWKEKkt5wS7n9Xn3QvTEZP+DHoYjHzU8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=PRJD4ZK+0+/P8eBr+okecJG4JqZgmqRpZG36LB7GfAUo2jlljGNvV22Kgu97kxGLupoYIQiQoNhl84jP4DET4Zc/ki29R6YVPIILdNbViSTMj1eQnO5nIbx+EVLwqxFRPgyBP2qH5kAxX3I33szOyNz/+3vox6LT5ifKcZJ0CFg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ATKFYzzI; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716818795; x=1748354795; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=esIMTSoe6zhhWKEKkt5wS7n9Xn3QvTEZP+DHoYjHzU8=; b=ATKFYzzIsf2+U6xydAlgQ3eqLc49wzopNkQVjDUaNcIsaxSatNfMtGEb JA9olKH2YASp//sD+JkoSfgK5fkjSyJ22VmkDEmxkVK9es4/cDqPKeNVk Wg1aDnWGvT9ps4NViygumJTYJfOMmC/D6Mk+UapPIJ/TmaqOAhwbCYdrB hiV7T+T4a9ytbyeEXYdpHV92i0tjmqy1BiKBBBn/ap6YgK7Z5OghOoFeW wHggYvwcq9qH8dpd+CSKzJ6hGaM2cI5pOVSjeCeCFC7+P1JNhcOmK5pW4 8Ir08Wd+1zY1KEf4zrrX6JHr+dwYoflhtA17fUQl5+ZQWWQQaM1PTeSJU g==; X-CSE-ConnectionGUID: I0rErUnDQyW8T5HnDgyirg== X-CSE-MsgGUID: FmvaITcNSDC3LWLK1P10KQ== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="24267954" X-IronPort-AV: E=Sophos;i="6.08,192,1712646000"; d="scan'208";a="24267954" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2024 07:06:34 -0700 X-CSE-ConnectionGUID: vqCrNranR/GTPXOOHJpqbw== X-CSE-MsgGUID: a8cmA0bQR5WQoakChsMkzQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,192,1712646000"; d="scan'208";a="35260746" Received: from lfiedoro-mobl.ger.corp.intel.com (HELO localhost) ([10.245.246.200]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2024 07:06:32 -0700 From: Jani Nikula To: Andy Shevchenko Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Kees Cook , Andy Shevchenko Subject: Re: [PATCH 1/2] string: add mem_is_zero() helper to check if memory area is all zeros In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20240527094320.2653177-1-jani.nikula@intel.com> Date: Mon, 27 May 2024 17:06:28 +0300 Message-ID: <87jzjfmjrv.fsf@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, 27 May 2024, Andy Shevchenko wrote: > On Mon, May 27, 2024 at 12:43=E2=80=AFPM Jani Nikula wrote: >> >> Almost two thirds of the memchr_inv() usages check if the memory area is >> all zeros, with no interest in where in the buffer the first non-zero >> byte is located. Checking for !memchr_inv(s, 0, n) is also not very >> intuitive or discoverable. Add an explicit mem_is_zero() helper for this >> use case. > > ... > >> +static inline bool mem_is_zero(const void *s, size_t n) >> +{ >> + return !memchr_inv(s, 0, n); >> +} > > There are potential users for the 0xff check as well. Hence the > following question: > Are we going to have a new function per byte in question, or do we > come up with a common denominator, like mem_is_all_of(mem, byte)? No. As I wrote in the commit message rationale, "Almost two thirds of the memchr_inv() usages check if the memory area is all zeros". This is by far the most common use case of memchr_inv(). BR, Jani. --=20 Jani Nikula, Intel