Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1090229ybc; Tue, 19 Nov 2019 14:23:22 -0800 (PST) X-Google-Smtp-Source: APXvYqxQErvBGKPhS8ADwHfFATPqLSAofCjRzFxs7h8xR6UAU8sVytkBybA1ZU/VI2w0Z5+iPpog X-Received: by 2002:a17:906:cca:: with SMTP id l10mr353ejh.161.1574202202171; Tue, 19 Nov 2019 14:23:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574202202; cv=none; d=google.com; s=arc-20160816; b=Fdnbm2JepOgU3RGQLXCHzFkydddg2lzt73WehSLy8MGk0ICLUAJS6dMtu2RNLNIKcu hdqZ4psJjMmWfjEnFsc3KFC98eYwJ63eAcNFg/cZJAZrtqb9qSfoxV3GgqSQP7wLpElV Bns9rlAkbDyJnji+X7DguEB4ITLPPMF+tykt2cuBf5xUvREkekf9TUHMeaDXB2VpId/Q C7aSB7c3ax+SmcUC0MWknXW+X2qYX6YjIfs9fM8CMfqQTF6edoodHtXn99vU3YKrMMMO uFDnYTPkOhgbdFiFpPkLMX0FzBRXvR+Yo525bHRydDumHprISA+VHGlwKWdn7NTpQEHc HXXg== 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:mime-version :date:cc:to:from:subject:message-id:dkim-signature; bh=6gnMHWcz1HkD4X2H3XeYl1zHwzltviEq5WfWUQfGnzQ=; b=Bm7H6sE/mLXhV5DhpcS7LinAroW7k+ecXoN1LaDgyHNcOy9EdUBrI7Ev8ewAjNbiaN 20jjY0rdMNwFo32tp1/wBmLJDf9ehHsupt6Bhum0DHbNxHpMQJbfW2iCtQRuCWPgeUlt 6mM0rbyUuMueV4IM4A7IoFN8COQgIjmjGpcmnkCVmrHviQONeoAraXJeAnD29m/t+q3a 2UZOJmIaOPAE58lXfk9pVi7PaMgfeNUaDwZtqWcaVrYKi68jEX3yCYalFaPbjXoW9rqz RPzvcDKBA7m4ltDTsMBG0YzhNciWGkp3lXzBRBgV8qk0BqKd2NBlZoY3bR7ROcHQc9Fg WrHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.de header.s=2017 header.b=NlWa6PMa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c29si17482002edb.223.2019.11.19.14.22.58; Tue, 19 Nov 2019 14:23:22 -0800 (PST) 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=pass header.i=@posteo.de header.s=2017 header.b=NlWa6PMa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727925AbfKSWVA (ORCPT + 99 others); Tue, 19 Nov 2019 17:21:00 -0500 Received: from mout02.posteo.de ([185.67.36.66]:44643 "EHLO mout02.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726290AbfKSWU7 (ORCPT ); Tue, 19 Nov 2019 17:20:59 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 2D68D240101 for ; Tue, 19 Nov 2019 23:20:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1574202056; bh=6gnMHWcz1HkD4X2H3XeYl1zHwzltviEq5WfWUQfGnzQ=; h=Subject:From:To:Cc:Date:From; b=NlWa6PMapOkExiBm29qZbcMrKdv3CoEaJ6AuO7MxuFKJQ/DvwmYqbKs0/0UExQ9zj HkDMUOHbZz12r4Nf/3HgwQqBRuG/1EpPNjsmsB6fI6nPV/6SqnNuPpfV5uWtlOY2ss Ex7X4TBvr3lYkEqYDcXMJw3Ia7NPAtwQxZN2US9mfDvK5WxRJMqfRpPRtJU47vSkq+ nFllBSEHhUGQUZq6fplPKlcRT6BfnDl0JVOeq67jHaJClCJFpE7mctvB1mTJCXcS94 MBXidWg/wrxP9XWk1Y1gcq79lLLw5r7w5Ov093LlAf983029d8sHE/EwA/VrpAGvU1 xbJ1pvGfbve8Q== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 47HgJP08t5z9rxK; Tue, 19 Nov 2019 23:20:52 +0100 (CET) Message-ID: <1574202052.1931.17.camel@posteo.de> Subject: SCHED_DEADLINE with CPU affinity From: Philipp Stanner To: linux-kernel@vger.kernel.org Cc: Hagen Pfeifer , mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de Date: Tue, 19 Nov 2019 23:20:52 +0100 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hey folks, (please put me in CC when answering, I'm not subscribed) I'm currently working student in the embedded industry. We have a device where we need to be able to process network data within a certain deadline. At the same time, safety is a primary requirement; that's why we construct everything fully redundant. Meaning: We have two network interfaces, each IRQ then bound to one CPU core and spawn a container (systemd-nspawn, cgroups based) which in turn is bound to the corresponding CPU (CPU affinity masked).         Container0       Container1    -----------------  -----------------    |               |  |               |    |    Proc. A    |  |   Proc. A'    |    |    Proc. B    |  |   Proc. B'    |    |               |  |               |    -----------------  -----------------           ^                  ^           |                  |         CPU 0              CPU 1           |                  |        IRQ eth0           IRQ eth1 Within each container several processes are started. Ranging from systemd (SCHED_OTHER) till two (soft) real-time critical processes: which we want to execute via SCHED_DEADLINE. Now, I've worked through the manpage describing scheduling policies, and it seems that our scenario is forbidden my the kernel.  I've done some tests with the syscalls sched_setattr and sched_setaffinity, trying to activate SCHED_DEADLINE while also binding to a certain core.  It fails with EINVAL or EINBUSY, depending on the order of the syscalls. I've read that the kernel accomplishes plausibility checks when you ask for a new deadline task to be scheduled, and I assume this check is what prevents us from implementing our intended architecture. Now, the questions we're having are:    1. Why does the kernel do this, what is the problem with scheduling with       SCHED_DEADLINE on a certain core? In contrast, how is it handled when       you have single core systems etc.? Why this artificial limitation?    2. How can we possibly implement this? We don't want to use SCHED_FIFO,       because out-of-control tasks would freeze the entire container. SCHED_RR / SCHED_FIFO will probably be a better policy compared to SCHED_OTHER, but SCHED_DEADLINE is exactly what we are looking for. Cheers, Philipp