From mboxrd@z Thu Jan 1 00:00:00 1970 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 E2DA13890E8 for ; Fri, 13 Mar 2026 09:04:23 +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=1773392665; cv=none; b=jrSLq8Xw4iZS+iPUqjlMixbIxFm9Nvavlf6PK4nS00BCe60LdydxHr0Rfd/1m0Cc+XZWFiDxnrt1UPlz4WkAFy5BXQj9p3BbzChP1lSvGJ9low3NcWdIFgnsv05CXT5pFhvHtEksgj71yQce4khD+1yit1lSOiotA7UKoVkJk+o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773392665; c=relaxed/simple; bh=lVSY4JW0lj6HkIQab7P50g2P71ymh54oQGxE8x6HyyM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UVSveLpbtbpLYvzCUrmr/0ZjYNGb/9Lyt24e0WbTWb7DIWClZDmjLKSWHsOl1ArNHjQPMKf+mcSfsY1G0qjMFTBg2l1vnvHhgQrzZ10ir2vhzMAbXVBXKXkZhl9m+rvJ5udBMLKVcw0T/iWTtouZxZ9FAMMc8p6qrx4Aq84fros= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=PDe0LM9I; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PDe0LM9I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773392664; x=1804928664; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=lVSY4JW0lj6HkIQab7P50g2P71ymh54oQGxE8x6HyyM=; b=PDe0LM9Ifhpc1dxzPQ++aYokiIFsU6rcZJEwwUSr1jNEh91sNhOEqixX vwyhzU3TD1Wtr7SjWn2r39hYBYLN9tmxAstxe4reiPLR00KPIYHO8KkyJ GQYNegSxIE/+Gz8eSF4XZfKuJv5/4uYUu9JNWY5D/7UV6c4UzLxXm6aMQ GwcIGnEAHHPZKeAxKn8+ZU3pw2pRCk8opPHxxAx9iUbXGbLnBqiLmKp9X Tx/gsCWOgiD0Dl8FNtMMZa+7kByTfoJSgqYjIHQYWKJrdc/bhfd2wMjYX +p5RT2SovVBxLmxHuVkpie08ta7xckRkAAyu2zAlTgibICi+QAB1C2awY Q==; X-CSE-ConnectionGUID: QHHoe8FFT4i/c6ZMisBhBg== X-CSE-MsgGUID: +uHeULtAS6WMmvFa8LVEhA== X-IronPort-AV: E=McAfee;i="6800,10657,11727"; a="85583603" X-IronPort-AV: E=Sophos;i="6.23,117,1770624000"; d="scan'208";a="85583603" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 02:04:20 -0700 X-CSE-ConnectionGUID: L7DD1+k9RzuTk+yiO/qTTg== X-CSE-MsgGUID: zjURKxICQDay4DOlQDDUsQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,117,1770624000"; d="scan'208";a="221055934" Received: from pgcooper-mobl3.ger.corp.intel.com (HELO localhost) ([10.245.245.246]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2026 02:04:18 -0700 Date: Fri, 13 Mar 2026 11:04:15 +0200 From: Andy Shevchenko To: Josh Law Cc: Andrew Morton , Josh Law , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] lib/uuid: avoid double traversal in __uuid_parse() Message-ID: References: <20260312184113.23564-1-objecting@objecting.org> 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=us-ascii Content-Disposition: inline In-Reply-To: <20260312184113.23564-1-objecting@objecting.org> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Thu, Mar 12, 2026 at 06:41:13PM +0000, Josh Law wrote: > __uuid_parse() calls uuid_is_valid() to walk all 36 characters for > format validation, then walks the string a second time to parse the > hex bytes. Combine both passes into one: validate each hex digit > inline via hex_to_bin() return value and check the four dash positions > after the loop. > > uuid_is_valid() remains exported unchanged for callers that only need > validation without parsing. ... > - if (!uuid_is_valid(uuid)) > - return -EINVAL; In case if valid string it heats up the caches, no? > for (i = 0; i < 16; i++) { > int hi = hex_to_bin(uuid[si[i] + 0]); > int lo = hex_to_bin(uuid[si[i] + 1]); > + if (hi < 0 || lo < 0) > + return -EINVAL; Here we add a branch (or two, depending on the code generation) > b[ei[i]] = (hi << 4) | lo; > } > + if (uuid[8] != '-' || uuid[13] != '-' || > + uuid[18] != '-' || uuid[23] != '-') > + return -EINVAL; And one more here. > return 0; > } If you a really into performance, please, provide the tests and the results to show the benefit. Numbers will tell for themselves. -- With Best Regards, Andy Shevchenko