From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61559C433DB for ; Thu, 14 Jan 2021 19:45:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E0CF62343B for ; Thu, 14 Jan 2021 19:45:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E0CF62343B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4FF428D0118; Thu, 14 Jan 2021 14:45:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4AEF98D00F0; Thu, 14 Jan 2021 14:45:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39DC98D0118; Thu, 14 Jan 2021 14:45:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id 251318D00F0 for ; Thu, 14 Jan 2021 14:45:03 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CB060348D for ; Thu, 14 Jan 2021 19:45:02 +0000 (UTC) X-FDA: 77705408844.14.sign54_290a88b27529 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id B71E31822989D for ; Thu, 14 Jan 2021 19:45:02 +0000 (UTC) X-HE-Tag: sign54_290a88b27529 X-Filterd-Recvd-Size: 7839 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Thu, 14 Jan 2021 19:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610653501; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=L4fMtoOwJ5mUt/q2SmTdxTbqGRB0N1gXlsIgUmz4LbQ=; b=O5kZYG1QZcvED6RlN66T6wdCDMEdwRi3PTodQ0uHIZuYNfiil0WznjVXqKLbRgEkoTJ3MI /R6OqFLd/ptiBFby9JFxELIwELOi2sBq3SGo2l/2kx++lxhruUPDT0yOvCwFvSrARP1df5 aJVxIlz3Xzr6okLflb5wBRQTrDkLAFI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-562-vVvfc7WlOfGdI2rnag1PKA-1; Thu, 14 Jan 2021 14:44:59 -0500 X-MC-Unique: vVvfc7WlOfGdI2rnag1PKA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F1B341005313; Thu, 14 Jan 2021 19:44:57 +0000 (UTC) Received: from fuller.cnet (ovpn-112-5.gru2.redhat.com [10.97.112.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E885648A1; Thu, 14 Jan 2021 19:44:51 +0000 (UTC) Received: by fuller.cnet (Postfix, from userid 1000) id 917B2416D87F; Thu, 14 Jan 2021 16:34:30 -0300 (-03) Date: Thu, 14 Jan 2021 16:34:30 -0300 From: Marcelo Tosatti To: Christoph Lameter Cc: Alex Belits , "tglx@linutronix.de" , "pauld@redhat.com" , "linux-mm@kvack.org" , "frederic@kernel.org" , "willy@infradead.org" , "peterz@infradead.org" , "akpm@linux-foundation.org" , Juri Lelli , Daniel Bristot de Oliveira Subject: Re: [RFC] tentative prctl task isolation interface Message-ID: <20210114193430.GA149907@fuller.cnet> References: <20201117180356.GT29991@casper.infradead.org> <20201117202317.GA282679@fuller.cnet> <20201127154845.GA9100@fuller.cnet> <87h7p4dwus.fsf@nanos.tec.linutronix.de> <12ddb629555590cfd41db5b10854d95c1f154e24.camel@marvell.com> <20210113121544.GA16380@fuller.cnet> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mtosatti@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jan 14, 2021 at 09:22:54AM +0000, Christoph Lameter wrote: > On Wed, 13 Jan 2021, Marcelo Tosatti wrote: > > > So as discussed, this is one possible prctl interface for > > task isolation. > > > > Is this something that is desired? If not, what is the > > proper way for the interface to be? > > Sure that sounds liek a good beginning but I guess we need some > specificity on the features > > > +Task isolation CPU interface > > +============================ > > How does one do a oneshot flush of OS activities? ret = prctl(PR_TASK_ISOLATION_REQUEST, ISOL_F_QUIESCE, 0, 0, 0); if (ret == -1) { perror("prctl PR_TASK_ISOLATION_REQUEST"); exit(0); } > > I.e. I have a polling loop over numerous shared and I/o devices in user > space and I want to make sure that the system is quite before I enter the > loop. You could configure things in two ways: with syscalls allowed or not. Syscalls disallowed: =================== 1) Add a new isolation feature ISOL_F_BLOCK_SYSCALLS (to block certain syscalls) along with ISOL_F_SETUP_NOTIF (to notify upon isolation breaking): if ((ifeat & ISOL_F_BLOCK_SYSCALLS) == ISOL_F_BLOCK_SYSCALLS) { struct task_isolation_block_syscalls tibs = { list of syscalls to block, additional parameters } struct task_isolation_notif tis = { parameters to control signal handling upon isolation breaking event } ret = prctl(PR_TASK_ISOLATION_SET, ISOL_F_SETUP_NOTIF, &tis); if (ret != 0) { ... } featuremask |= ISOL_F_SETUP_NOTIF; ret = prctl(PR_TASK_ISOLATION_SET, ISOL_F_BLOCK_SYSCALLS, &tibs); if (ret != 0) { ... } featuremask |= ISOL_F_BLOCK_SIGNALS; featuremask |= ISOL_F_QUIESCE; } This would require knowledge of the behaviour of individual system calls, that is whether or not these syscalls cause the CPU to be a target of interruptions (1) (while the QUIESCE / HARD / WARN division you propose allows for coarse-grained control). Perhaps coarse control while also allowing finer grained control (if desired) is a useful choice? 1: for example adding free pages to per-cpu free lists. Syscalls allowed: ================= > In the loop itself some activities may require syscalls so they will > potentialy cause the OS services such as timers to start again. Or a different mode where the syscall return itself can finish any pending activities. > When such > an activities is complete another quiet down call can be issued. Although this seems more efficient (if multiple syscalls are to be used). > Could be implemented by setting a flag that does an action and then resets > itself? Or the flag could be reset if a syscall that requires timers etc > is used? You mean to let userspace know if a certain syscall triggered a pending action which must be finished (before "quiet mode" is entered again) ? Sounds like a good idea. > Features that I think may be needed: > > F_ISOL_QUIESCE -> quiet down now but allow all OS activities. OS > activites reset flag > > F_ISOL_BAREMETAL_HARD -> No OS interruptions. Fault on syscalls that > require such actions in the future. Question: why BAREMETAL ? Two comments: 1) HARD mode could also block activities from different CPUs that can interrupt this isolated CPU (for example CPU hotplug, or increasing per-CPU trace buffer size). Unclear whether such blockage should be performed on: -> Individual action basis (eg: BLOCK_CPU_HOTPLUG, BLOCK_PERCPU_TRACEBUFFER_SIZE, ...) (which could allow individual unblocking through a sysfs interface, for example). Or -> Be tied to a flag with a less implementation specific meaning such as F_ISOL_BAREMETAL_HARD. 2) For a type of application it is the case that certain interruptions can be tolerated, as long as they do not cross certain thresholds. For example, one loses the flexibility to read/write MSRs on the isolated CPUs (including performance counters, RDT/MBM type MSRs, frequency/power statistics) by forcing a "no interruptions" mode. That flexibility seems to be useful (so perhaps F_ISOL_BAREMETAL_HARD but optionally permitting certain interruptions). > F_ISOL_BAREMETAL_WARN -> Similar. Create a warning in the syslog when OS > services require delayed processing etc > but continue while resetting the flag. Alex seems to be interested in different notification methods as well. Thanks for the input.