Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp6087069ybl; Tue, 27 Aug 2019 14:15:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqyekc/Fwp5vZ24LAQLHqZ0m2m0nj2HdbE5j01tdk75Gye6Q4jDG8mR5A8xuA8hRF0qp/BPM X-Received: by 2002:a17:90a:9a7:: with SMTP id 36mr758028pjo.93.1566940548988; Tue, 27 Aug 2019 14:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566940548; cv=none; d=google.com; s=arc-20160816; b=SER3Cp6Ie1xyHpjYibWK+W0fiobK24b3ojcarEpzWfWG43P3HHUSZeB//X40OpYhWw XjGwXa44US8AG9dvK9GlfDi7c+7reYYCv9XFEWuZhhovTGywTlfEM0ckrsR6jDIcISzd j9VplkdTLuyLoG3zm3l8bQIb3QtWYiN6FIbpMSYAqXmERNTFky++8cs0hrA7nDtMZgCh wi+ZPEcPjvTaOPIHXQSIfEN6n3teiTKXCB6l7al08gM6yKm1LkMY5fZ87bCyg35bjZKQ S434pz7CCZVLkFuD218xKSlUx9KzupWWwg7e2QAgOKRS82DwJAnc/sn7whZJR8t2cmJM Aqww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Mx9Dk0y/TBT36EVwZByK1hsTBU2mCJBn5CqiJJkzVLg=; b=rYwxM3G804j10xiHiG0Ahf/KmJAy2yWR8iy45xrdbDfVoQDsyGpydD4+SDqUJMKYxE UvjXWQxmvMJxbheVTqfTcUTncQWv32Q9X0YCWo/YLWDos/lzgvh0s9OThTvfbBU4PTTV o5ojCvrZ3da/CPpJh9CHdI1BN+QW/AfMfwMvlMFCMEuMBlD88scGn+aKfPywFcbj4Hzg QB3Sm5jaW1mJMcMnJqsD2px6p4VgpP4igIkYsrZxqho51tFGB0x0MZirqTJg//w1PzdS WCwvBEefORL6B9vVcsvGclMdS7jyfBgfFesWivkOQ7xyPthyomW256Ih7MlVSgtRJz1I r2Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@codon.org.uk header.s=63138784 header.b=W1ovLiBG; 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 w10si240244pgr.212.2019.08.27.14.15.33; Tue, 27 Aug 2019 14:15:48 -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=fail header.i=@codon.org.uk header.s=63138784 header.b=W1ovLiBG; 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 S1729903AbfH0VOi (ORCPT + 99 others); Tue, 27 Aug 2019 17:14:38 -0400 Received: from cavan.codon.org.uk ([93.93.128.6]:40114 "EHLO cavan.codon.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726735AbfH0VOi (ORCPT ); Tue, 27 Aug 2019 17:14:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codon.org.uk; s=63138784; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Mx9Dk0y/TBT36EVwZByK1hsTBU2mCJBn5CqiJJkzVLg=; b=W1ovLiBG+dKXEhJcPYqAthsG5 lO7UH68rMmm/aUW6+VJjzE5WIvCXi1esvPkkO0TnyumOoV0vJqKUJRZMm97hAsyCWTQ4zfsJsUu60 HWux9CGbT+LTgBwf23oijcC7MmvT/+nsPJrsNEJmMMEpKjfBMyIEPCY+pNrDVLA/bmmCI=; Received: from mjg59 by cavan.codon.org.uk with local (Exim 4.89) (envelope-from ) id 1i2inB-000246-T5; Tue, 27 Aug 2019 22:14:17 +0100 Date: Tue, 27 Aug 2019 22:14:17 +0100 From: Matthew Garrett To: Vineeth Remanan Pillai Cc: Nishanth Aravamudan , Julien Desfossez , Peter Zijlstra , Tim Chen , mingo@kernel.org, tglx@linutronix.de, pjt@google.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, subhra.mazumdar@oracle.com, fweisbec@gmail.com, keescook@chromium.org, kerrnel@google.com, Phil Auld , Aaron Lu , Aubrey Li , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini Subject: Re: [RFC PATCH v3 00/16] Core scheduling v3 Message-ID: <20190827211417.snpwgnhsu5t6u52y@srcf.ucam.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: mjg59@cavan.codon.org.uk X-SA-Exim-Scanned: No (on cavan.codon.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Apple have provided a sysctl that allows applications to indicate that specific threads should make use of core isolation while allowing the rest of the system to make use of SMT, and browsers (Safari, Firefox and Chrome, at least) are now making use of this. Trying to do something similar using cgroups seems a bit awkward. Would something like this be reasonable? Having spoken to the Chrome team, I believe that the semantics we want are: 1) A thread to be able to indicate that it should not run on the same core as anything not in posession of the same cookie 2) Descendents of that thread to (by default) have the same cookie 3) No other thread be able to obtain the same cookie 4) Threads not be able to rejoin the global group (ie, threads can segregate themselves from their parent and peers, but can never rejoin that group once segregated) but don't know if that's what everyone else would want. diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h index 094bb03b9cc2..5d411246d4d5 100644 --- a/include/uapi/linux/prctl.h +++ b/include/uapi/linux/prctl.h @@ -229,4 +229,5 @@ struct prctl_mm_map { # define PR_PAC_APDBKEY (1UL << 3) # define PR_PAC_APGAKEY (1UL << 4) +#define PR_CORE_ISOLATE 55 #endif /* _LINUX_PRCTL_H */ diff --git a/kernel/sys.c b/kernel/sys.c index 12df0e5434b8..a054cfcca511 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -2486,6 +2486,13 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, return -EINVAL; error = PAC_RESET_KEYS(me, arg2); break; + case PR_CORE_ISOLATE: +#ifdef CONFIG_SCHED_CORE + current->core_cookie = (unsigned long)current; +#else + result = -EINVAL; +#endif + break; default: error = -EINVAL; break; -- Matthew Garrett | mjg59@srcf.ucam.org