Received: by 10.213.65.68 with SMTP id h4csp748248imn; Fri, 23 Mar 2018 15:19:30 -0700 (PDT) X-Google-Smtp-Source: AG47ELvP/IhoZBjEmjtebEaVpeXnwcGua0QxBZPsoDskgV/+PIXVcZlAb7zqGsVxL7f9p8QCsDD6 X-Received: by 2002:a17:902:144:: with SMTP id 62-v6mr31579878plb.202.1521843570600; Fri, 23 Mar 2018 15:19:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521843570; cv=none; d=google.com; s=arc-20160816; b=NubSzKz9NZSteZ4kseqROt+4qd2STiben34jrSww/mA4HTvcBuGfZl8XcmqwN/w2Ld GfuAfMKtIm/ou0EZaJ9QXJwUhoydaIeCWwzKbvKLh6EgpFHhQmLVisz4m7amQ3Z0r7I9 R/BolDPAFwDA9uJb9LFAp+Qws4arB4YiHV+OdBL/xNZwtJkKoNeG7pulCYT53ycZMhMr bkmpE5W68gF3+m7HUpUymIsmqRa3VVEjOmKgxjyz6iJkXwBCxR7hnz5VzfoBXm5NgKjJ O6OXs1O9t71mbdIhoIsO16eeZQBlmjsT21djZTKr1d9elQHxthXpL5ikLqTL6P1XVD5x eBOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=aM5DOEjZPf/Tbf6GVbgIyF/x1iI/pSQOg8OyzCKSOJA=; b=jRmcpFGMu7PcBbLwg4cH5v5JDaFZRsSZrViVDHP03js+e1UyVbQQwwZ6GutKDzkh85 +RHlJc+/Vq7YiuaePV72W6+H+R3VXZqHsB3MC3F7SGuiJ0123apEntEmLHunfHJKE0IH mWkxOjqP/3twrVwhmotVDPbY3c66Di9V5XVOZcpPE6/zJh0ZXbGvE2E1FzNZXTWpCMfS cD61BKa3WCbwcLaj51bDFImDDFnFU0S+PKPNRtTopwqDX7Qcxpp+HQFlg7sYApQheV2b JG90q899RTplwtnh4fzwdh8baJc9txA2EITughliGRHHc9tS0h4dICeaqNKy9VX5fQjQ SHBg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z19si6532268pgn.46.2018.03.23.15.19.16; Fri, 23 Mar 2018 15:19:30 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752112AbeCWWSP (ORCPT + 99 others); Fri, 23 Mar 2018 18:18:15 -0400 Received: from terminus.zytor.com ([198.137.202.136]:39001 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751715AbeCWWSO (ORCPT ); Fri, 23 Mar 2018 18:18:14 -0400 Received: from hanvin-mobl2.amr.corp.intel.com ([192.55.54.44]) (authenticated bits=0) by mail.zytor.com (8.15.2/8.15.2) with ESMTPSA id w2NMHjMv029123 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Fri, 23 Mar 2018 15:17:45 -0700 Subject: Re: [PATCH v3 2/2] x86, cpuid: allow cpuid_read() to schedule To: Eric Dumazet , x86 Cc: lkml , Eric Dumazet , Thomas Gleixner , Borislav Petkov , Ingo Molnar , Hugh Dickins References: <20180323215818.127774-1-edumazet@google.com> <20180323215818.127774-2-edumazet@google.com> From: "H. Peter Anvin" Message-ID: <3622b64c-bae6-00db-6a61-3ccf760144aa@zytor.com> Date: Fri, 23 Mar 2018 15:17:44 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180323215818.127774-2-edumazet@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/23/18 14:58, Eric Dumazet wrote: > I noticed high latencies caused by a daemon periodically reading various > MSR and cpuid on all cpus. KASAN kernels would see ~10ms latencies > simply reading one cpuid. Even without KASAN, sending IPI to CPU > in deep sleep state or blocking hard IRQ in a a long section, > then waiting for the answer can consume hundreds of usec or more. > > Switching to smp_call_function_single_async() and a completion > allows to reschedule and not burn cpu cycles. That being said, the Right Way for a daemon to read multiple MSRs and CPUIDs on multiple CPUs is to spawn a thread for each CPU and use CPU affinity to lock them down. No IPI is needed to access MSRs on the current CPU, and CPUID doesn't even need kernel entry. -hpa