Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp620387pxj; Fri, 11 Jun 2021 07:23:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW7UhdtQbN2c3pa2cLvw3awEr5EFKGl27qTfoCyFCKEtjJC+yV1gZiUZMQtBDiIPLOvxXR X-Received: by 2002:a17:906:4f91:: with SMTP id o17mr3956651eju.219.1623421424910; Fri, 11 Jun 2021 07:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623421424; cv=none; d=google.com; s=arc-20160816; b=Mb8GhOkCQ2YbbPngis6Sn4GA3YDoYN8Y9jr8smy9Pux2HfOg6VHtYini3bUqR6r7fd HXqbGp8iRLD2Ev9R7g0livssjXRw6jV80/RldHYz7Jc5iGviRD0l8cGtiSSn6PcJWOg/ MlO8flpEFu6G8nV2DLzn64zU4QwcBOBMp3thTBOVbhfMJ2S8TkZcLGZuJ5kOeq9qUUAM 7ISjWXyhPiRpgxUCIepBF1GlppE43VNiuwyRgjI8gMLiIGBhwE2PVHCAKTAgAvlX3e3Q UJM4UOchcM7zoNFzndgcIIMlCiKLfO8Xa3EMwmCwS6qVweENta57OhBaWboyALwV/oVQ TjFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=cLoguh9c2z7MQMLfe3C8ZzxQs8vSxwn/Q8pWHOqfCU8=; b=PUOpiTY+1zEFTF2qnvduol5W/Cz4H7JD3wRYoQN5Ro/7SlxRxYtDh2PzamrdpysL5o Pg7hJHwDWV9UGceLLFG5dNa5VEE419ggWNyh04Vd+FFinekUmuJuPENBwNSkNBcmdQKX SMfEfFfhzbuudPXgDdvJy+mxpA/RW/At97AJElhv3hInbtmlYpHikfgXj1MLhk+cCO2U BG+CyNdkSxlSnHTm01dT64YBrr4zStz47dDtN3MGizF2i/ptCB46hOB4aVg9BsZrYfQV 9Jkw/CUyN6BbBWqRf1OFVwsmdARxp04bGbLLOc9LFcKUVKuNZYmCfFkFSUJsRgX2pvX7 wjEw== 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=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u5si5255204ejy.632.2021.06.11.07.23.20; Fri, 11 Jun 2021 07:23:44 -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=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231627AbhFKOVe (ORCPT + 99 others); Fri, 11 Jun 2021 10:21:34 -0400 Received: from foss.arm.com ([217.140.110.172]:59708 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231584AbhFKOVd (ORCPT ); Fri, 11 Jun 2021 10:21:33 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4026B1FB; Fri, 11 Jun 2021 07:19:35 -0700 (PDT) Received: from e113632-lin (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A8A973F73D; Fri, 11 Jun 2021 07:19:34 -0700 (PDT) From: Valentin Schneider To: paulmck@kernel.org Cc: frederic@kernel.org, linux-kernel@vger.kernel.org Subject: Re: Question about a8ea6fc9b089 ("sched: Stop PF_NO_SETAFFINITY from being inherited by various init system threads") In-Reply-To: <20210611135207.GB4397@paulmck-ThinkPad-P17-Gen-1> References: <20210610170435.GA2187550@paulmck-ThinkPad-P17-Gen-1> <8735tpd15i.mognet@arm.com> <20210610201713.GU4397@paulmck-ThinkPad-P17-Gen-1> <87zgvwbtgy.mognet@arm.com> <20210611135207.GB4397@paulmck-ThinkPad-P17-Gen-1> Date: Fri, 11 Jun 2021 15:19:29 +0100 Message-ID: <87r1h8bi1a.mognet@arm.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/06/21 06:52, Paul E. McKenney wrote: > On Fri, Jun 11, 2021 at 11:12:29AM +0100, Valentin Schneider wrote: >> >> The way I see 570a752b7a9b is that, if a task is pinned to a single CPU but >> doesn't have PF_NO_SETAFFINITY, then userspace can unpin it. This means it >> ought to have entered check_preemption_disabled() with preemption disabled >> - right now it may be pinned, but that can change at any minute, and >> whatever code it is running needs to cope with that. > > Thank you for catching me up on this topic! > >> Could you share some details on which tasks you are hitting this with? > > Let's start with ref_scale_reader() in kernel/rcu/refscale.c. This > is for fine-grained in-kernel benchmarking, so it really wants kthreads > running this function to be pinned. > > I took a look at kthread_bind(), but it is not intended to be called by > the kthread itself. Looking elsewhere in the kernel, it looks like I > just do this right after invoking set_cpus_allowed_ptr(): > > current->flags != PF_NO_SETAFFINITY; > > Or am I missing a better way to handle this? Looking at ref_scale_reader(), ISTM the initial configuration (affinity, niceness) should be done by its parent thread, not by itself. i.e.: p = kthread_create(ref_scale_reader); kthread_bind(p, cpu); // Does the pinning + sets PF_NO_SETAFFINITY set_user_nice(p, MAX_NICE); wake_up_process(p); (kthread_create_on_cpu() is also an option) From what I can see, torture_create_kthread() immediately wakes the newly-created kthread, we'd need a version that calls kthread_create() instead of kthread_run() for the above. Would that be an issue? > > Thanx, Paul