Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1036714pxa; Wed, 12 Aug 2020 21:30:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/41UZg/UcVnKLsUhFLUaBYGhgd83XZBxLJN8WsWkoy1HTyT2rgdCuZ56y5dNvYWu2Nnpz X-Received: by 2002:a17:906:819:: with SMTP id e25mr3126062ejd.95.1597293005214; Wed, 12 Aug 2020 21:30:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597293005; cv=none; d=google.com; s=arc-20160816; b=dCUJ9cc0uHnr3Lteb4Br+pOFHHsYNCbz/gqjl1QzmPUXgYByWW63fBVTspLamd0hmL X+dSAgCcLDAIJYmcnL9AiPr07NwnfTi96qA8J8X+hIqGCezCbZQN43JeL305EhNMH0Lt Mof3gLtcXE73S6/qiGZZyi59YEGrP3LZWFNe1ecpIxIhcA6cxDFmGlskZZVObGNt1UIA 1VZnj3+l0CZZDxe3xjZMEnFa/b6alncUYxGJ8eYBQU+tST5x0QCaEaBhU2FLJ9lufj3G 09ezc8UcGoWM+N0OHkFuLuL87vtYhBkY348tfePZRbLOM1gCoSJ/4YVhn42A0Ydag2oR WyEg== 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:ironport-sdr:ironport-sdr; bh=LHxy98Dl6FirzYHmkc3yCtjFK1S0Wm+6wCm+fCYxFL4=; b=FSskNaweQ41RQFdTLUlQuQsR6EttLdO6TI+w4dxq6l8BoWPVqvvJsUMxWbbi1UTIL2 o0fHr3KpJAv/ePaKSK5HxnIPPa7PxDCPfAMz2NXplSByve3vpPfTOPQWlnsEb9wgBQ27 efvDQtvOo8VtJ5hb+YTgw31CU0owiF2tvlo7HoJjvABeICgzOxwzYa7OY8HPC4EMo61t vbcqPedniJFSbeoQ+FA0bVtFJMm5uIcEn8lxUgVpl0bDHBBEOMGaUSqCLpYmGg6lrT/J xDO+Uc9sgelhZiC3VaJyw91cEm32OewP1Sg2lgiyx9ghPx+DASI/fpT8k0QH5d84L5w0 xzyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp15si3259023ejc.199.2020.08.12.21.29.40; Wed, 12 Aug 2020 21:30:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725915AbgHME2Y (ORCPT + 99 others); Thu, 13 Aug 2020 00:28:24 -0400 Received: from mga01.intel.com ([192.55.52.88]:31185 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725298AbgHME2Y (ORCPT ); Thu, 13 Aug 2020 00:28:24 -0400 IronPort-SDR: SQbbSeBalEOukS2Xb6ZmeqCo5vOT1SvG5gINMP0UwnwpXRUmAkJziPpyus6mGZcNbWempls3Bu jcJbcqKjHB9A== X-IronPort-AV: E=McAfee;i="6000,8403,9711"; a="172202402" X-IronPort-AV: E=Sophos;i="5.76,307,1592895600"; d="scan'208";a="172202402" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 21:28:23 -0700 IronPort-SDR: /ACyUcJn18/+Hkmk3BvP4mZwpa4w3qWHFYTA8ZSQmPHlSyfZdzHr+Vb6Tj3r2mtr53YbTLCQzj gnVZ7u3ZhwRA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,307,1592895600"; d="scan'208";a="318382678" Received: from cli6-desk1.ccr.corp.intel.com (HELO [10.239.161.135]) ([10.239.161.135]) by fmsmga004.fm.intel.com with ESMTP; 12 Aug 2020 21:28:17 -0700 Subject: Re: [RFC PATCH 00/16] Core scheduling v6 To: Joel Fernandes Cc: viremana@linux.microsoft.com, Nishanth Aravamudan , Julien Desfossez , Peter Zijlstra , Tim Chen , Ingo Molnar , Thomas Glexiner , Paul Turner , Linus Torvalds , LKML , Subhra Mazumdar , Frederic Weisbecker , Kees Cook , Greg Kerr , Phil Auld , Aaron Lu , Aubrey Li , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini , Vineeth Pillai , Chen Yu , Christian Brauner , "Ning, Hongyu" , =?UTF-8?B?YmVuYmppYW5nKOiSi+W9qik=?= References: <6d0f9fc0-2e34-f559-29bc-4143e6d3f751@linux.intel.com> <20200809164408.GA342447@google.com> <162a03cc-66c3-1999-83a2-deaad5aa04c8@linux.intel.com> <20200812230850.GA3511387@google.com> From: "Li, Aubrey" Message-ID: <5a39735d-dfd8-bdec-f068-81895799640e@linux.intel.com> Date: Thu, 13 Aug 2020 12:28:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200812230850.GA3511387@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 2020/8/13 7:08, Joel Fernandes wrote: > On Wed, Aug 12, 2020 at 10:01:24AM +0800, Li, Aubrey wrote: >> Hi Joel, >> >> On 2020/8/10 0:44, Joel Fernandes wrote: >>> Hi Aubrey, >>> >>> Apologies for replying late as I was still looking into the details. >>> >>> On Wed, Aug 05, 2020 at 11:57:20AM +0800, Li, Aubrey wrote: >>> [...] >>>> +/* >>>> + * Core scheduling policy: >>>> + * - CORE_SCHED_DISABLED: core scheduling is disabled. >>>> + * - CORE_COOKIE_MATCH: tasks with same cookie can run >>>> + * on the same core concurrently. >>>> + * - CORE_COOKIE_TRUST: trusted task can run with kernel >>>> thread on the same core concurrently. >>>> + * - CORE_COOKIE_LONELY: tasks with cookie can run only >>>> + * with idle thread on the same core. >>>> + */ >>>> +enum coresched_policy { >>>> + CORE_SCHED_DISABLED, >>>> + CORE_SCHED_COOKIE_MATCH, >>>> + CORE_SCHED_COOKIE_TRUST, >>>> + CORE_SCHED_COOKIE_LONELY, >>>> +}; >>>> >>>> We can set policy to CORE_COOKIE_TRUST of uperf cgroup and fix this kind >>>> of performance regression. Not sure if this sounds attractive? >>> >>> Instead of this, I think it can be something simpler IMHO: >>> >>> 1. Consider all cookie-0 task as trusted. (Even right now, if you apply the >>> core-scheduling patchset, such tasks will share a core and sniff on each >>> other. So let us not pretend that such tasks are not trusted). >>> >>> 2. All kernel threads and idle task would have a cookie 0 (so that will cover >>> ksoftirqd reported in your original issue). >>> >>> 3. Add a config option (CONFIG_SCHED_CORE_DEFAULT_TASKS_UNTRUSTED). Default >>> enable it. Setting this option would tag all tasks that are forked from a >>> cookie-0 task with their own cookie. Later on, such tasks can be added to >>> a group. This cover's PeterZ's ask about having 'default untrusted'). >>> (Users like ChromeOS that don't want to userspace system processes to be >>> tagged can disable this option so such tasks will be cookie-0). >>> >>> 4. Allow prctl/cgroup interfaces to create groups of tasks and override the >>> above behaviors. >> >> How does uperf in a cgroup work with ksoftirqd? Are you suggesting I set uperf's >> cookie to be cookie-0 via prctl? > > Yes, but let me try to understand better. There are 2 problems here I think: > > 1. ksoftirqd getting idled when HT is turned on, because uperf is sharing a > core with it: This should not be any worse than SMT OFF, because even SMT OFF > would also reduce ksoftirqd's CPU time just core sched is doing. Sure > core-scheduling adds some overhead with IPIs but such a huge drop of perf is > strange. Peter any thoughts on that? > > 2. Interface: To solve the performance problem, you are saying you want uperf > to share a core with ksoftirqd so that it is not forced into idle. Why not > just keep uperf out of the cgroup? I guess this is unacceptable for who runs their apps in container and vm. Thanks, -Aubrey > Then it will have cookie 0 and be able to > share core with kernel threads. About user-user isolation that you need, if > you tag any "untrusted" threads by adding it to CGroup, then there will > automatically isolated from uperf while allowing uperf to share CPU with > kernel threads. > > Please let me know your thoughts and thanks, > > - Joel > >> >> Thanks, >> -Aubrey >>> >>> 5. Document everything clearly so the semantics are clear both to the >>> developers of core scheduling and to system administrators. >>> >>> Note that, with the concept of "system trusted cookie", we can also do >>> optimizations like: >>> 1. Disable STIBP when switching into trusted tasks. >>> 2. Disable L1D flushing / verw stuff for L1TF/MDS issues, when switching into >>> trusted tasks. >>> >>> At least #1 seems to be biting enabling HT on ChromeOS right now, and one >>> other engineer requested I do something like #2 already. >>> >>> Once we get full-syscall isolation working, threads belonging to a process >>> can also share a core so those can just share a core with the task-group >>> leader. >>> >>>>> Is the uperf throughput worse with SMT+core-scheduling versus no-SMT ? >>>> >>>> This is a good question, from the data we measured by uperf, >>>> SMT+core-scheduling is 28.2% worse than no-SMT, :( >>> >>> This is worrying for sure. :-(. We ought to debug/profile it more to see what >>> is causing the overhead. Me/Vineeth added it as a topic for LPC as well. >>> >>> Any other thoughts from others on this? >>> >>> thanks, >>> >>> - Joel >>> >>> >>>>> thanks, >>>>> >>>>> - Joel >>>>> PS: I am planning to write a patch behind a CONFIG option that tags >>>>> all processes (default untrusted) so everything gets a cookie which >>>>> some folks said was how they wanted (have a whitelist instead of >>>>> blacklist). >>>>> >>>> >>