Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4382337pxv; Tue, 27 Jul 2021 06:10:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIQWLrayuIq8FGipsqXH9Jx8M0Ps2mKqThxJKoVPGLL8e5j6mt7av3prZNsJ3xZF00AlEM X-Received: by 2002:a5d:5703:: with SMTP id a3mr8825515wrv.333.1627391429460; Tue, 27 Jul 2021 06:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627391429; cv=none; d=google.com; s=arc-20160816; b=yJEmzNPiMwOlJb7Kx9pJ+ADERA1+rfD0lFKYUi2BRalmzRNbmzaWbabMALDIFN0PjJ PvrZMHbm6kB+/5GZ1lzt4a26+mqKBaPVIXSxTaVsvKRgR6dPsBHTyafNF9cSsqOYP+NF vFKO4gvX/1v6tugZYLMX6jtd0aOa+loysbobtvn87ds5pjI5OrmiJVBfCMnqf9stj5Aa ny527Vpt2j42G0UYHvl4Kk0j69TpAjNnlMMjcPa3iczFwMIC1pJAOfjE2HKW/yDRNNJF bQiJox7DVOV5CD1RlnUSZg62AjDqxesXT07+VAyuVkc9o6Az+aRX496hhfsXZosW9yYi hSEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2oQ5Q8rJseViqRDSIPWll9c/hpUVWxSXj+4+osHv2nY=; b=FjUefVAN5NYIKnkelmd5AyGGNsEXQ5firhgdjTirQ41XDkP47VZ+QqVgbiaf9R3Ey+ 92HvNeiuzM+Of0BgJWQyRRVh7Quges8nggAbHTz56GAUvNDKENYtYOWLTXZrGTX5j8mi Re+VYbmo63PAOoh7kBasCclDSau1cCH4efug17qarey9+is6exzZ2b+1DghmmdcH/Ur7 +U+vc1HlDrPIkYErCHe09wynfpA6zRuqjdknjfVbz0g7KTjokTiyLRZfIuUJNsx2g7KZ vb0DU5VVMs+XyDbxjARlqYPraK+U9xSH4DSk/ljnSo54e8PNRGxobewSsh9Dxy6WOL8Q tr4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FDJuG0A8; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id op26si3227502ejb.415.2021.07.27.06.10.05; Tue, 27 Jul 2021 06:10:29 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FDJuG0A8; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232163AbhG0NIo (ORCPT + 99 others); Tue, 27 Jul 2021 09:08:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23347 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232123AbhG0NIn (ORCPT ); Tue, 27 Jul 2021 09:08:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627391323; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2oQ5Q8rJseViqRDSIPWll9c/hpUVWxSXj+4+osHv2nY=; b=FDJuG0A8jC3GN2LdqE7DNsP3tX7mDM30PqqTI4uJAAzRKgB4ZPp7SBYDRNL0DtzYB2q/Kb bV7vlq1quSrxGLTwnd8bCaEINsuTGRLySK8c6CeRHk9+rAn3dlWOly9d7QrLA79MIvwMAX T3ouWfnfjxhH/GsFNny03mrA2wluEqI= 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-447-SyR271NxN3mzUnsXJC5PNQ-1; Tue, 27 Jul 2021 09:08:40 -0400 X-MC-Unique: SyR271NxN3mzUnsXJC5PNQ-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 7F36F100E420; Tue, 27 Jul 2021 13:08:38 +0000 (UTC) Received: from fuller.cnet (ovpn-112-6.gru2.redhat.com [10.97.112.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D6671B46C; Tue, 27 Jul 2021 13:08:31 +0000 (UTC) Received: by fuller.cnet (Postfix, from userid 1000) id 905F34172EDB; Tue, 27 Jul 2021 10:08:27 -0300 (-03) Date: Tue, 27 Jul 2021 10:08:27 -0300 From: Marcelo Tosatti To: nsaenzju@redhat.com Cc: linux-kernel@vger.kernel.org, Nitesh Lal , Frederic Weisbecker , Christoph Lameter , Juri Lelli , Peter Zijlstra , Alex Belits , Peter Xu Subject: Re: [patch 1/4] add basic task isolation prctl interface Message-ID: <20210727130827.GB508962@fuller.cnet> References: <20210727103803.464432924@fuller.cnet> <20210727104119.551607458@fuller.cnet> <7b2d6bf91d30c007e19a7d2cbddcb2460e72d163.camel@redhat.com> <20210727110050.GA502360@fuller.cnet> <20210727130641.GA508962@fuller.cnet> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210727130641.GA508962@fuller.cnet> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 27, 2021 at 10:06:41AM -0300, Marcelo Tosatti wrote: > On Tue, Jul 27, 2021 at 02:38:15PM +0200, nsaenzju@redhat.com wrote: > > Hi Marcelo, > > > > On Tue, 2021-07-27 at 08:00 -0300, Marcelo Tosatti wrote: > > > On Tue, Jul 27, 2021 at 12:48:33PM +0200, nsaenzju@redhat.com wrote: > > > > On Tue, 2021-07-27 at 07:38 -0300, Marcelo Tosatti wrote: > > > > > +Isolation mode (PR_ISOL_MODE): > > > > > +------------------------------ > > > > > + > > > > > +- PR_ISOL_MODE_NONE (arg4): no per-task isolation (default mode). > > > > > + PR_ISOL_EXIT sets mode to PR_ISOL_MODE_NONE. > > > > > + > > > > > +- PR_ISOL_MODE_NORMAL (arg4): applications can perform system calls normally, > > > > > + and in case of interruption events, the notifications can be collected > > > > > + by BPF programs. > > > > > + In this mode, if system calls are performed, deferred actions initiated > > > > > + by the system call will be executed before return to userspace. > > > > > + > > > > > +Other modes, which for example send signals upon interruptions events, > > > > > +can be implemented. > > > > > > > > Shouldn't this be a set of flags that enable specific isolation features? > > > > Something the likes of 'PR_ISOL_QUIESCE_ON_EXIT'. Modes seem more restrictive > > > > and too much of a commitment. If we merge MODE_NORMAL as is, we won't be able > > > > to tweak/extend its behaviour in the future. > > > > > > Hi Nicolas, > > > > > > Well, its assuming PR_ISOL_MODE_NORMAL means "enable all isolation > > > features on return to userspace". > > > > > > Later on, if desired, can add extend interface as follows (using > > > Christoph's idea to not perform automatic quiesce on return to > > > userspace, but expose which parts need quiescing > > > so userspace can do it on its own, as an example): > > > > > > #define PR_ISOL_QUIESCE_ON_EXIT (1<<0) > > > #define PR_ISOL_VSYSCALL_PAGE (1<<1) > > > ... > > > > > > unsigned long bitmap = PR_ISOL_VSYSCALL_PAGE; > > > > > > /* allow system calls */ > > > prctl(PR_ISOL_SET, PR_ISOL_MODE, PR_ISOL_MODE_NORMAL, 0, 0, 0); > > > > > > /* > > > * disable quiescing on exit, enable reporting through > > > * vsyscall page > > > */ > > > prctl(PR_ISOL_SET, PR_ISOL_FEATURES, &bitmap, 0, 0); > > > /* > > > * configure vsyscall page > > > */ > > > prctl(PR_ISOL_VSYSCALLS, params, ...); > > > > > > So unless i am missing something, it is possible to tweak/extend the > > > interface. No? > > > > OK, sorry if I'm being thick, but what is the benefit of having a distincnt > > PR_ISOL_MODE instead expressing everything as PR_ISOL_FEATURES. > > > > PR_ISOL_MODE_NONE == Empty PR_ISOL_FEATURES bitmap > > > > PR_ISOL_MODE_NORMAL == Bitmap of commonly used PR_ISOL_FEATURES > > (we could introduce a define) > > > > PR_ISOL_MODE_NORMAL+PR_ISOL_VSYSCALLS == Custom bitmap > > > > Other than that, my rationale is that if you extend PR_ISOL_MODE_NORMAL's > > behaviour as new features are merged, wouldn't you be potentially breaking > > userspace (i.e. older applications might not like the new default)? > > > > -- > > Nicol?s S?enz > > The main reason is that PR_ISOL_MODE would allow for distinct > modes to be implemented (matching each use case). For example: > > https://lwn.net/Articles/816298/ > > "When a task has finished its initialization, it can activate isolation > by using the PR_TASK_ISOLATION operation provided by the prctl() > system call. This operation may fail for either permanent or temporary > reasons. An example of a permanent error is when the task is set up > on a CPU without isolation; in this case, entering isolation mode > is not possible. Temporary errors are indicated by the EAGAIN error > code; examples include a time when the delayed workqueues could not be > stopped. In such cases, the task may retry the operation if it wants to > enter isolation, as it may succeed the next time. > > In the prctl() call, the developer may also configure the signal to be > sent to the task when it loses isolation. The additional macro to use is > PR_TASK_ISOLATION_SET_SIG(), passing it the signal to send. The command > then becomes similar to the one in the example code:" But have no strong preference: fine with PR_ISOL_FEATURES as you describe above, and if that is the consensus, can resubmit.