Received: by 10.213.65.68 with SMTP id h4csp827578imn; Fri, 23 Mar 2018 18:02:23 -0700 (PDT) X-Google-Smtp-Source: AG47ELu/ozcQf5Bmp2zyFZPWvSOUKsi/zlXk5duW1Q4BEE/kz7+WNRuHGAgOOYCkp1wbiAeujvI5 X-Received: by 2002:a17:902:7401:: with SMTP id g1-v6mr31867590pll.4.1521853343897; Fri, 23 Mar 2018 18:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521853343; cv=none; d=google.com; s=arc-20160816; b=i7nf2w3lQVVMv4ioD2ERmBIYnmoDjgBpnk8Q1uDbUQxOyE9eB5AKYrx7TDcvUsz0Oa c3rqQdIcMv8NjNFmhfX/pIhfUtSg62F5Beusblc47KxyT7pGPibM5b0U920e+X8PqGq4 C3SxWwrXqSZ43e+mWEcCPqTo4FCfBJrQMjarPE85GFDmH21OF533gwRdV7vCABIuOWKn EHPnqneTjVC3ZIFD19RV7yooiuJ0Ivb2i0rZLd08PPVxIVwFEWaNSkZxkTgOq6H3hdmJ DnyYz0+F4buNDOYvkTe7P0rIisJxNMv9vlwFrd5ySkgVatKuAOdo5u+cJMYGstTABUNL MC5Q== 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:dkim-signature :arc-authentication-results; bh=Ggg8EU9SmYuzYjER+r6GG5k/Pqot7UpYyptOJ1Vh6MQ=; b=Q2SOZN1+fzJYVzua1+2fGB9jQtl2eVPDyv7cbPv1lUYMhb2G8ZZ9QGnYkMtM1Vw9tZ JIbybIuT+MrxUWaC03RcK506OWgrhLJmrkUPQiazGH6DagxUSLY8HGPe9+Y6kOqVa+bG /1mv9X6s7hPmspS/lXK2gzd+Dpc/it3JZ/WGnw8FNvAA+D64TDOlbQDAsZYe/8ytTjoI mYP+AVUVcDzagvLjvfkxsW3aYESM3asRDuEF3pq16ZKFap9tRP844Cqckbp4FyydTUyD EsatmBYPyBeFrmsSWY19uxsLShSUlr8zLTMa8ltxGLkSPqfqH8PserspUyio8YHw/chg ApvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NZr+Lm9Z; 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 65-v6si9591577plb.573.2018.03.23.18.02.07; Fri, 23 Mar 2018 18:02:23 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NZr+Lm9Z; 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 S1751847AbeCXBBK (ORCPT + 99 others); Fri, 23 Mar 2018 21:01:10 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:33076 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751400AbeCXBBJ (ORCPT ); Fri, 23 Mar 2018 21:01:09 -0400 Received: by mail-pl0-f66.google.com with SMTP id c11-v6so8449423plo.0 for ; Fri, 23 Mar 2018 18:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Ggg8EU9SmYuzYjER+r6GG5k/Pqot7UpYyptOJ1Vh6MQ=; b=NZr+Lm9ZT0n8K/ecW0GKkOPA5+KGwlmGlhDUaap51TBcx2qR7+A3JE0jzC/Fg261Hj iRjO5OdnNoiE5YlH7abmM84a66zZ7/+Lp7uIgf/omexUQ5RqoekrIUdbDZ7d64BRyhie gCt+bGrkOe/g/0Pb1ZqHV85zsrwYL0pXB70V2SKwv2UvHKQLVh3H+y+WkQGO8mL7iAt/ dwWDb8xEQY7fwdNW4rqmwJ2fn558zWjPVviyXkY6o4Wks8F1+HkWKxFfLe/QvTOT3PEG Bm9Lo0/QVamBKZ8m2Fp+RwSqq88qkTGvpPslK2rxvGL7NYZtwgsNXUYJJ+6CL0EtIMx4 Tc+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Ggg8EU9SmYuzYjER+r6GG5k/Pqot7UpYyptOJ1Vh6MQ=; b=ZM/JVXvy4CNpUxaggBj13W1QXHylkf1UmQX4NlIlkvqOecuE3PP3eioCvsd31QHjJb qJuErWyQ0fompNRfJ9xel7WDVWMd9xF639qg+7Pg6bmHR55+q87DVyrPWK66LXym1ZQQ VZ+ZozVcLJgU7zBaoqE5xWYgcCY+kPWtrbjSJ2kFtx9/F/odX/WCL7oVb3P188gTOpHj NGWwt6F1t3qnupeIoJQf+9FOuBquVDP1eSr+hZfA2qgd8cSuprU/ZeMnH6T20nx5j21E zwN9ZpdE0WklteV3msyfNNHPa2GqyL91S9nrSFXiORZmqw/VA9tay+6uxGavM4ljsI6a cVEg== X-Gm-Message-State: AElRT7EZIbmwvNUULg2+PsX1AjCdWjrxvmC4PvHSDPrHxaWkyFLZVwGb qe3ejPv1NO6TYKocqOmZQTY= X-Received: by 2002:a17:902:24:: with SMTP id 33-v6mr31460424pla.341.1521853269134; Fri, 23 Mar 2018 18:01:09 -0700 (PDT) Received: from [192.168.86.235] (c-67-180-167-114.hsd1.ca.comcast.net. [67.180.167.114]) by smtp.gmail.com with ESMTPSA id 26sm19584392pfn.68.2018.03.23.18.01.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Mar 2018 18:01:08 -0700 (PDT) Subject: Re: [PATCH v3 2/2] x86, cpuid: allow cpuid_read() to schedule To: "H. Peter Anvin" , Eric Dumazet , x86 Cc: lkml , Thomas Gleixner , Borislav Petkov , Ingo Molnar , Hugh Dickins References: <20180323215818.127774-1-edumazet@google.com> <20180323215818.127774-2-edumazet@google.com> <3622b64c-bae6-00db-6a61-3ccf760144aa@zytor.com> From: Eric Dumazet Message-ID: Date: Fri, 23 Mar 2018 18:01:07 -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: <3622b64c-bae6-00db-6a61-3ccf760144aa@zytor.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/2018 03:17 PM, H. Peter Anvin wrote: > 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. Indeed, assuming a daemon can have threads running on all cpus :/ Some environments like to partition cpus for different jobs/containers. Yes, we can avoid IPI by carefully re-designing these user programs.