Received: by 10.213.65.68 with SMTP id h4csp1252099imn; Sat, 24 Mar 2018 07:31:00 -0700 (PDT) X-Google-Smtp-Source: AG47ELvw/rBgJJiUwJMNS3LTU18puUNePTltXjC3nPwtxepgAc0h4a4xxzy/4LLQoUcjStYi7va1 X-Received: by 2002:a17:902:4225:: with SMTP id g34-v6mr17103854pld.297.1521901860736; Sat, 24 Mar 2018 07:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521901860; cv=none; d=google.com; s=arc-20160816; b=gMiEsdJV9uOCPOUwoF3D3E8NZIszPj3VxKqYJyDM26HQxI++Bz3yBtiNFNEWn8PKK0 p/gLS2alh55JCLPVrivFyb704o8VfUbGCfPcU2g8t/7LQjojQQwvhXChJxov57XG9jf8 DO+uGbRTkQYz2KK3C4uO/Vj57NiTbZLjihm3pgZPSKZJUKHrX+CCg0woTF3rCXSzmgYU 6iB+Y7e7DMyb2mlTCOzkR4tJWygIKXoPLSr/MbDWjL6xa8VvZEZ8Fnct19QD3EfRguF8 XduRExTYxuG4OvmGnuRiVeYqQp1CdVsRf88nsHAfu8GlpBvTuMkgRRPGq1CzFS7FtI6q se5g== 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=swd62kIRhDlILIu7e8Vd5ngVmP9Q0RVQats8rmdNcoY=; b=sbWeLVyAAGtxyqAS7PM/+RmNOKYa4qUu/BIOUchYgQAaHz7O7a3ACVabnIDmjiaOnS orNN/RoP/FHBLBTQMOhKIA7ygkACSuBJ6JvqjJsOxY0+qbVydQLV1Uo8//xlSVGgnX/U O1o6pEB6qDVdRBwEmhix2UDifoxjyShsEEVYNDR1+AdWWWJT7nb2B1JP6CWvEGjrHeo4 Nle4pXRc0CgOs4ZAD1Q6zveDbl//Fun0W9A0pkvReIv4PHXgrS+440bP6lSOjQVk+mHm RtD2Wvv67NG4ni0tYpcHotaosP54SISck5MpD9DEQTpm5cysFUI0ReKTxyVuVUdXRZbv nMjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=K3h2J8xS; 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 e6si7478637pgt.442.2018.03.24.07.30.46; Sat, 24 Mar 2018 07:31:00 -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=K3h2J8xS; 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 S1752338AbeCXO3w (ORCPT + 99 others); Sat, 24 Mar 2018 10:29:52 -0400 Received: from mail-pg0-f53.google.com ([74.125.83.53]:45660 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752258AbeCXO3v (ORCPT ); Sat, 24 Mar 2018 10:29:51 -0400 Received: by mail-pg0-f53.google.com with SMTP id y63so2503369pgy.12 for ; Sat, 24 Mar 2018 07:29:51 -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=swd62kIRhDlILIu7e8Vd5ngVmP9Q0RVQats8rmdNcoY=; b=K3h2J8xSyGdscd1TmAQSAm9rZMrPVNFMgfc+TwMklD73tVGdzl9NgPffzggXB8G1U1 9DCJ1JRIEkQd+oqeEM2ldUUCfSb6KGAPlKcq6D/cqrMLsV055uChTtW7Q8Yq4Kgd5Li9 uLROm8GLX+NMl1UX2MfsC6+fBtrniXnue013ZGL8lKvnqPXaKluEAq/kOgkleWRW293C QxcU3hWAmTN+hkC4w6PuU1b+uDrKTbfDv4ZrrO4kedpaWMjDEXjLl8NUXIO650+5gSOx 5WM29RVWlL5cgAtR5yA9hZclYnO/8CR6+Jru//pOdrhIZEvkuXftMxNCtI+meSC2viWp MIig== 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=swd62kIRhDlILIu7e8Vd5ngVmP9Q0RVQats8rmdNcoY=; b=LSLJVLEOTSiVOju/UvAW5ByjwpRyIlJseVhKCH34IUXrPnDZEKtd6Ru5r04Qecqanm oHd1yVumeEED2Wk9b2FmYZ1+vAta1eQttdkNOCPdvUtKIjQgNfZ5Y+D0hIptW64LefKo EozVhzIEANZFtWJs2V1YsAn21fyM0PCIAj2FJ7E3owV3KYBCkNWwZsRYalxsfxwhVqqh G0YwkkYuVdOO5hhIc+QJhcOyKUL8CTcehTPkbc+L0gO4t8oo9x9cJVqQ5xYq+G3+Go18 ur/v2hFs/a4Kom6UI7f7dZDBpqr5tJrBZohNIZN31rhTOpdoZltqzgQzEWWhOcrAG1Fo lZnQ== X-Gm-Message-State: AElRT7GVhnIvdNXxlntt7txUe5P9H/nPL28a6JzXVF2ddjRmwi+JHFsa oYJRKAzfWH33ptvc/CclC8U= X-Received: by 10.99.152.10 with SMTP id q10mr12900966pgd.40.1521901790661; Sat, 24 Mar 2018 07:29:50 -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 d77sm25050108pfe.20.2018.03.24.07.29.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Mar 2018 07:29:49 -0700 (PDT) Subject: Re: [PATCH v3 1/2] x86, msr: allow rdmsr_safe_on_cpu() to schedule To: Ingo Molnar , Eric Dumazet Cc: x86 , lkml , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Hugh Dickins , Peter Zijlstra References: <20180323215818.127774-1-edumazet@google.com> <20180324080946.3db4xdkl5i6jx2rc@gmail.com> From: Eric Dumazet Message-ID: <336355a3-c11d-44fc-0642-671670980ac0@gmail.com> Date: Sat, 24 Mar 2018 07:29:48 -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: <20180324080946.3db4xdkl5i6jx2rc@gmail.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/24/2018 01:09 AM, Ingo Molnar wrote: > > * Eric Dumazet wrote: > >> I noticed high latencies caused by a daemon periodically reading >> various MSR on all cpus. KASAN kernels would see ~10ms latencies >> simply reading one MSR. 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. >> >> Converts rdmsr_safe_on_cpu() to use a completion instead >> of busy polling. >> >> Overall daemon cpu usage was reduced by 35 %, >> and latencies caused by msr_read() disappeared. > > What "daemon" is this and why is it reading MSRs? It is named gsysd, "Google System Tool", a daemon+cli that is run on all machines in production to provide a generic interface for interacting with the system hardware. I am not sure if this answers your question, I probably could give a rough estimation of MWh this daemon consumes on the planet if that helps. Note that the source of the problem is not reading the MSR, but having cpus blocking hard irqs for a long time. Ingo, it looks like any loop protected by unlock_task_sighand() might be the main offender. Application writers seem to love getrusage() for example. Can we rewrite it to not block hard irqs ? Thanks !