Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp501458lqo; Thu, 16 May 2024 12:20:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUigKCpwJd9zWa+vne0Joz0FDrlVL6C5VrIu9vN7N6VHkUDl3iwLZkqahCDN3owCKDUYpxGNgzTHoQ845oU3YKZf3nyjspOvS2q4JGuag== X-Google-Smtp-Source: AGHT+IGO8/kXctP/Rf5j/OcN6OY+XfZNPpXN4nngB3AdPYrgc+3weKxahnGuMGSi1R+MugD3LgOt X-Received: by 2002:a17:90a:6886:b0:2ae:6e16:da91 with SMTP id 98e67ed59e1d1-2b6cc97d217mr17255406a91.29.1715887211723; Thu, 16 May 2024 12:20:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715887211; cv=pass; d=google.com; s=arc-20160816; b=DqC+ScCAjL2Enwka0KTcriwl5r64VTbPFuTebqLZoDV01+344cljh9vTxMLRbZQs/o VottN5cKPFeii+LjmZKP23ZU46ZIpZEUT1jX8nKAp2iWif3qaLk9DaeLGFEX4DM7xBDu FiuIt2QK88qES90poxLc+GE7Pfdu+sZeaUwjMIZ+bkR+VoFuWcF4lrA/wEl0e9KuwcOu aRGMC6ngXYs3Im0aBkJbwvhqGm2xSD2T+yd9M9JL0R1XWITjUwQ3Z0Qz4SFR2q/YWXQ5 kFKViGr8KirBtarQYLJKf7VbW9wOtRXse7ulDV8vl5z2N25Q2j1+6jbtlCp1ON2XWruD 2WdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from; bh=wnTr9MgTMJe8htLM4f6S5S5Y/Ex6cH3hfBLm9DbMXbA=; fh=fjxQdQzao48DpSTVNhUE1DboNF90bOrz5HX9NYZN1yM=; b=DtswTGWD5XqYgXzNISXSrYYVTFTS01V5BWORlWBK5JgnwtMOYIwtAZNPDcUOWTwX3c iiSBi/02VLEwevPk4eFsmiqL+ycbVf2kZoIT91kdliFdHRsPV1KuIy+CUntpxPx0oW4m m1CdEfOQ3RYYE0ptmq8LCOE0eFf3ElwtC6mBGHRhUU1KWo41+ziXB4deb6Sa8gU7kvfM YcMsh91Y1vLfrDbUaxUPTbDnYlMOW/CYOuNcA4Yd5algc5aVzKkdC7t1A4HaKBqMlskm 5WH4COICXGPV236zZgOreBepgSoZZw9J6dUXJZKG8kAG265aGW9kmRajN8dg9fgyUP1y Ds7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-181525-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181525-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b671589ca3si16344849a91.147.2024.05.16.12.20.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 12:20:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181525-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-181525-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181525-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 505C42898BD for ; Thu, 16 May 2024 19:14:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 842CA15CD6F; Thu, 16 May 2024 19:09:05 +0000 (UTC) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5560115B98F; Thu, 16 May 2024 19:09:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715886544; cv=none; b=p6CViOusHAUtJIoERw3w4CDlbsWgDYnDfv8Ulj/3TglabjP2dTAkXoqKJUs5Otpfc3X82VoufzvkeZH/9EFsNS9aaX5Q27Z/OPI2dB9Q2byPi8v6zGG3HeF/+2vEa/27I63vNRmLt2jAtFbJXXDKjHn6LXJdqrl5aYqJPIDIA0k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715886544; c=relaxed/simple; bh=07edSisiBn7OLTKr0n/HQrCmFHqhyjayvCzG4MBk1co=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t3uXNupS305fTYTjGjE+8S5PWYh1BipS1PDApKcJcgl/3SvmtPKLFQtkXWnZ3Ut8xD23XpTN8EwGDahlNuS10gdzUdbQUneQrBkOQ9xFxnuK6r/Nr6ZxC6YLTx4nGMhD03C+sAeDEBbwHNZavT7XOZnlWHpdJMMupuoAyNf1CGI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-351b683f2d8so4105982f8f.3; Thu, 16 May 2024 12:09:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715886541; x=1716491341; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wnTr9MgTMJe8htLM4f6S5S5Y/Ex6cH3hfBLm9DbMXbA=; b=pomh7jhJIardVGFaumuvR+325WWYowmIV3adinsNP5tYpDnMQs4xjXOxsV3EuhjH76 6D68X+i3cd7Z9/0MsOfjfRmKBtjum/pxPgT6T8dPbWg48FxsCwyhqGoPx81WluV6xVmn Urj6ER33v0jL70rdt8CB+yiSrpIXOQFuLFlhR6sqAVvaUFjqMmD3Fp9UNTk1xPRzEd2i Gjo1Qj9iS+YsexBcIdXbOk0nKsmkN9CrJGSpe6VenD+A1l1MadjZJba7iRnS3HQanK4G gPVXw1+S3p4UMuCfqMdJRVebQB1aTcHULuYSfML2MI8SE58gGSwXHoFIVQXML4S6jpKS yg7g== X-Forwarded-Encrypted: i=1; AJvYcCV5tcrKmjpBXU5h0DDhONA5K9dhDSLAT7ulo5S8dPh3IvsG5f3QuDwmm7QQqCF8QmzX44s0e1Me9rl4YPGzx9MFSFahi4GEqqP+cxJdUdFLqYl5ggS/R2mzra+JzMgDYs3+L99R8Q== X-Gm-Message-State: AOJu0YzG/QbFxZu1wPRoaE8RCVKBJghpUL86aSAHbzo9tulu2UnPVtZc C1k4JCp9k2bRhuJVTHjGpAXK09UGNJpOVlyjLxvjY/s27zKdAGu0 X-Received: by 2002:a05:600c:19c8:b0:41f:e2c5:6618 with SMTP id 5b1f17b1804b1-41feac5512amr145661405e9.32.1715886541644; Thu, 16 May 2024 12:09:01 -0700 (PDT) Received: from costa-tp.redhat.com ([2a00:a040:1a3:c059:8b18:f13e:da9b:5a8e]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41fccee9335sm275834155e9.29.2024.05.16.12.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 12:09:01 -0700 (PDT) From: Costa Shulyupin To: longman@redhat.com, pauld@redhat.com, juri.lelli@redhat.com, prarit@redhat.com, vschneid@redhat.com, Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Zefan Li , Tejun Heo , Johannes Weiner , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Petr Mladek , Andrew Morton , Masahiro Yamada , Randy Dunlap , Yoann Congal , "Gustavo A. R. Silva" , Nhat Pham , Costa Shulyupin , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Subject: [PATCH v1 7/7] [NOT-FOR-MERGE] test managed irqs affinity adjustment Date: Thu, 16 May 2024 22:04:37 +0300 Message-ID: <20240516190437.3545310-8-costa.shul@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240516190437.3545310-1-costa.shul@redhat.com> References: <20240516190437.3545310-1-costa.shul@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Kernel module to generatemanaged irqs for the test and shell commands. Signed-off-by: Costa Shulyupin --- tests/managed_irq.c | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/managed_irq.c diff --git a/tests/managed_irq.c b/tests/managed_irq.c new file mode 100644 index 0000000000000..fd4e91e44e59d --- /dev/null +++ b/tests/managed_irq.c @@ -0,0 +1,71 @@ +#include +#include +#include + +/* + * Testing instructions: + * + * isolate=1 + * insmod managed_irq.ko test_cpu=$isolate + * cd /sys/fs/cgroup/ + * echo +cpuset > cgroup.subtree_control + * mkdir test + * echo isolated > test/cpuset.cpus.partition + * echo $isolate > test/cpuset.cpus + * read test_irq < /sys/module/managed_irq/parameters/test_irq + * + * cat /proc/irq/$test_irq/smp_affinity_list + * + * read affinity < /proc/irq/$test_irq/smp_affinity + * test 0 -ne $((0x$affinity & 1 << $isolate)) && echo FAIL | PASS + * + * Assure that irq affinity doesn't contain isolated cpu. + */ + +static int test_cpu = 1; +module_param(test_cpu, int, 0444); + +static int test_irq; +module_param(test_irq, int, 0444); + +static irqreturn_t test_irq_cb(int irq, void *dev_id) +{ + return IRQ_HANDLED; +} + +static int test_set_affinity(struct irq_data *d, const struct cpumask *m, bool f) +{ + irq_data_update_effective_affinity(d, m); + return 0; +} + +static int make_test_irq(void) +{ + struct irq_affinity_desc a = { + mask: *cpumask_of(test_cpu), + is_managed: true + }; + int test_irq = __irq_alloc_descs(-1, 1, 1, 0, THIS_MODULE, &a); + static struct irq_chip test_chip = { .irq_set_affinity = + test_set_affinity }; + + irq_set_chip(test_irq, &test_chip); + irq_set_status_flags(test_irq, IRQ_MOVE_PCNTXT); + pr_debug("test_irq=%d\n", test_irq); + int err = request_irq(test_irq, test_irq_cb, 0, "test_affinity", 0); + + if (err) + pr_err("%d\n", err); + + return test_irq; +} + +static int managed_irq_init(void) +{ + test_irq = make_test_irq(); + return 0; +} + +module_init(managed_irq_init); + +MODULE_LICENSE("GPL"); -- 2.45.0