From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.zytor.com (terminus.zytor.com [198.137.202.136]) (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 BD16719ABB6; Fri, 17 Jan 2025 16:18:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.136 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737130720; cv=none; b=aYLnLEK8eEXZfBAMMYoOtbrfU0br/iHbDK7tZc7GuZCbAxnRzFemUM7j7/jRnjwmKPHtYbJeNJzpYS5E1CSbc6nudbFRpR2At+FHfsdQRU75LGv7UfavADBXG/YZuvwEls1IzHALHqZFlg7JV9I+7Og7J4/79qhlALyB5Xtj6ks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737130720; c=relaxed/simple; bh=sNB1uFZu2mloisjdFqNHk8gx5JdSczvBHoAr2NbAulY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mTUSSRslJNfLTkq86s7OVaphWujTIdTmBQKcNrDAtbTlmF7r74bURmny1M6nOAZGgEe6D4USBZrJWjX0me5/1Df4xAqyADmCES3u4nyTm9ZAd0lZv0C99Noirw7GhYZcYlOUmN8hRn+k9cOfcivJm9svaNNvbRwlBV99POqLJp0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com; spf=pass smtp.mailfrom=zytor.com; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b=lZbQ85YO; arc=none smtp.client-ip=198.137.202.136 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zytor.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b="lZbQ85YO" Received: from [IPV6:2601:646:8080:c1f1:e386:c572:17d3:6ddc] ([IPv6:2601:646:8080:c1f1:e386:c572:17d3:6ddc]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 50HGHe8n033816 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Fri, 17 Jan 2025 08:17:41 -0800 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 50HGHe8n033816 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2024121701; t=1737130662; bh=OPSHPuabXC/5Wx6kXSJEUR24EKV1g+IykVWVbIKLyHo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=lZbQ85YOnalhAQ/mMnubxBiGj2rzjIjzUSmFR9bsSsV9NZC5iHe082wO55Gj295ja lSrj8TOz2ro6hkXJDMDf+62qi0apCfa3UKrZyYHJP06RaX+z2hbFmo8eyIWDDKCiSY ZbDB6cjmG7WBn1/wFhDIJOSZxAg8u9stR3M8rFY5Nz/4xWOelPUbC1E+XL+N7cZ33G icMHeQBRqAhksIvo0GvgFKhC0gSQ9jUmJl6KLc9fvcvuoWKqsxgJ4t5fe7vngHGq3N ZEtjR0EXm/ahCZBVj3Z97W7CrJBaMLtdbkfuTTs/Jv2YGe+W4825JkYEoB+TcMBfaE Q+Ov2Hh+eOyMg== Message-ID: <21a2dc23-a87f-42aa-b5c0-ab828b1c6ad8@zytor.com> Date: Fri, 17 Jan 2025 08:17:35 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] x86/fred: Optimize the FRED entry by prioritizing high-probability event dispatching To: Xin Li , Ethan Zhao , Ethan Zhao , linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: tglx@linutronix.de, dave.hansen@linux.intel.com, x86@kernel.org, andrew.cooper3@citrix.com, mingo@redhat.com, bp@alien8.de References: <20250116065145.2747960-1-haifeng.zhao@linux.intel.com> <417271c4-0297-41da-a39b-5d5b28dd73f9@zytor.com> <05b13e99-c7e5-4db7-90bd-a89a91f4e327@zytor.com> <56b92130-7082-422c-952c-9834ebdb7268@linux.intel.com> <4d485294-959b-42a6-a847-513e8e3d0070@zytor.com> <33b89995-b638-4a6b-a75f-8278562237c4@linux.intel.com> Content-Language: en-US From: "H. Peter Anvin" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 1/16/25 21:54, Xin Li wrote: > On 1/16/2025 9:18 PM, Ethan Zhao wrote: >>> >>> Just swap the 2 arguments, and it should be: >>> +    switch_likely (etype, EVENT_TYPE_OTHER) { >>> >>> >> after swapped the parameters as following: >> +#define switch_likely(v,l) \ >> + switch((__typeof__(v))__builtin_expect((v),(l))) >> + >>   __visible noinstr void fred_entry_from_user(struct pt_regs *regs) >>   { >>          unsigned long error_code = regs->orig_ax; >> +       unsigned short etype = regs->fred_ss.type & 0xf; >> >>          /* Invalidate orig_ax so that syscall_get_nr() works >> correctly */ >>          regs->orig_ax = -1; >> >> -       switch (regs->fred_ss.type) { >> +       switch_likely (etype, (EVENT_TYPE_EXTINT == etype || >> EVENT_TYPE_OTHER == etype)) { > > This is not what I suggested, the (l) argument should be only one > constant; __builtin_expect() doesn't allow 2 different constants. > The (l) argument is not a boolean expression! It is the *expected value* of (v). -hpa