From nobody Fri Dec 19 17:53:01 2025 Received: from mail-qv1-f74.google.com (mail-qv1-f74.google.com [209.85.219.74]) (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 2E52A1DE8AE for ; Mon, 14 Apr 2025 20:09:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744661380; cv=none; b=TnpPhBoGDptbBc5D8RwXz2htPz80SjonRQyz1ElQCNjShv+8D14KNDI8SQWR+F/snoWGnNk/uao1NpH+Qfksbzrvl9ot7Du9gjJyfzQJZB4+ZkE6Rgg5CKuvmJtwcH17UIYnwi/l615F5JnScuIgSgGFuLbfYqLWPml6aJuX0d4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744661380; c=relaxed/simple; bh=Q5s04arBO6wP0YtImTtLVVwE4rPFfsjS9e7jXcuiB/U=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=T5iF5uUN0eaKK9ZG/yfkfbxcsG9Lkh/K7hbsp04KeYuuxzjWT2cZRwqyVox4kwbegqyB5vFpzkdu+rq12IxVUs9xT+p93EmRwEG3hJIjO6PsPVmC0WYcEI7FWArjFAHBHEKywqa/fZUYkTsULVcuZdkxqEMyLZEflDRcmUvtjsU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jthoughton.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=wJmvWFiY; arc=none smtp.client-ip=209.85.219.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jthoughton.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="wJmvWFiY" Received: by mail-qv1-f74.google.com with SMTP id 6a1803df08f44-6ecfbdaaee3so78454636d6.3 for ; Mon, 14 Apr 2025 13:09:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1744661377; x=1745266177; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=3ZNC09kfFvwbMY+TuFPooH5ZpXiI2zM5Sfzza51R45o=; b=wJmvWFiYg9QaVghWy5s5AXVGVAxY7585xwC2gINmLTtz5CGwUbvbq+ta4FOHqIg7TW 4XAnExKQOIRcjok6lelBg8AJg7gYswe/WHJdNXIAjBZLdlpZhH4RqY/Z4cDgjO35XkfZ v1LkpG9NdPFeZ2Mp7UgKY3nUzsCDi6JM6Dq17KpkvBdEuzP2Jjrva0GrWKPQ5TMv+Ypv YAIN/eyFFpJLPTrNjgvcFl3JAEGJJ9eTJVXXQCOfBf18T6ZGYE8VRuBKruYnOWlJO/tk MVgiln6lrs10eMzmaqStcvmu0icEmtQUHfNPHZKcqYFCJBLFOW0avywDGLuU0mItTDw5 9MTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744661377; x=1745266177; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3ZNC09kfFvwbMY+TuFPooH5ZpXiI2zM5Sfzza51R45o=; b=gmTJ9k6nIzPGR96SF/sd0Yw7TqbHinniz/AMxGOpDOdtofMo+CWLGdXfJY6ZMlgci2 XTHwDh6IllfaSp7hoQD3jeqBFHQ7bNHjJM17/b0kKSvreoE4MTkt0NjL2BRH49aaecUY qzoa3YxS2372NwnGxAAxUHgIYzPz8wH4L11twjkS8MKq7QzcqJMHy9ghl0QfAdw8biH1 4AeQzU/fGBvB8DSRCfznByCPCiKSHz3n/clqwJS+RjgdMcIwqYEvYETYMZJOCJOxSoZM Lrxx/grm29eKIu1nwnAJJ6RiQZDGiYdM8rEQ8w5B913KLI2vgsEOt1J9QK9hx/CBMebZ RAdw== X-Forwarded-Encrypted: i=1; AJvYcCULus35AGW/A9Sxo3z3S3MfQqmR+PAbUNaC8SO6GOcHXOQP/4s8ZmzGesLzDqapWUCRAWtCaGo/Swc/kLQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwhPDY2oFZ3xTTxc4vMIyYLy3NUwS7Yfrkbw0JhRBQvxcbIogPC Eq1M5aBvTuWK4boTOdNdZuUYLr5PRVMDB30S3178TAwQ/+mrt2dZ5FV4PqhOwgmSY34TZI731or hoNEy78QJEcU+ExdPsw== X-Google-Smtp-Source: AGHT+IEmhHPOtSLRv5SjgoAz4o7I3BOkLb3Ktb52XwE92Hh9Nyak79yxZ3UyDRTI9exZl8vbFvxhssgNe4SMJrXM X-Received: from qvb1.prod.google.com ([2002:a05:6214:6001:b0:6eb:2b16:6854]) (user=jthoughton job=prod-delivery.src-stubby-dispatcher) by 2002:ad4:5ca4:0:b0:6f0:e2d4:51fe with SMTP id 6a1803df08f44-6f230d950dfmr184580506d6.26.1744661376927; Mon, 14 Apr 2025 13:09:36 -0700 (PDT) Date: Mon, 14 Apr 2025 20:09:27 +0000 In-Reply-To: <20250414200929.3098202-1-jthoughton@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250414200929.3098202-1-jthoughton@google.com> X-Mailer: git-send-email 2.49.0.604.gff1f9ca942-goog Message-ID: <20250414200929.3098202-4-jthoughton@google.com> Subject: [PATCH v3 3/5] cgroup: selftests: Move cgroup_util into its own library From: James Houghton To: Sean Christopherson , kvm@vger.kernel.org Cc: Maxim Levitsky , Axel Rasmussen , Tejun Heo , Johannes Weiner , mkoutny@suse.com, Yosry Ahmed , Yu Zhao , David Matlack , James Houghton , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" KVM selftests will soon need to use some of the cgroup creation and deletion functionality from cgroup_util. Suggested-by: David Matlack Signed-off-by: James Houghton --- tools/testing/selftests/cgroup/Makefile | 21 ++++++++++--------- .../selftests/cgroup/{ =3D> lib}/cgroup_util.c | 2 +- .../cgroup/{ =3D> lib/include}/cgroup_util.h | 4 ++-- .../testing/selftests/cgroup/lib/libcgroup.mk | 19 +++++++++++++++++ 4 files changed, 33 insertions(+), 13 deletions(-) rename tools/testing/selftests/cgroup/{ =3D> lib}/cgroup_util.c (99%) rename tools/testing/selftests/cgroup/{ =3D> lib/include}/cgroup_util.h (9= 9%) create mode 100644 tools/testing/selftests/cgroup/lib/libcgroup.mk diff --git a/tools/testing/selftests/cgroup/Makefile b/tools/testing/selfte= sts/cgroup/Makefile index 1b897152bab6e..e01584c2189ac 100644 --- a/tools/testing/selftests/cgroup/Makefile +++ b/tools/testing/selftests/cgroup/Makefile @@ -21,14 +21,15 @@ TEST_GEN_PROGS +=3D test_zswap LOCAL_HDRS +=3D $(selfdir)/clone3/clone3_selftests.h $(selfdir)/pidfd/pidf= d.h =20 include ../lib.mk +include lib/libcgroup.mk =20 -$(OUTPUT)/test_core: cgroup_util.c -$(OUTPUT)/test_cpu: cgroup_util.c -$(OUTPUT)/test_cpuset: cgroup_util.c -$(OUTPUT)/test_freezer: cgroup_util.c -$(OUTPUT)/test_hugetlb_memcg: cgroup_util.c -$(OUTPUT)/test_kill: cgroup_util.c -$(OUTPUT)/test_kmem: cgroup_util.c -$(OUTPUT)/test_memcontrol: cgroup_util.c -$(OUTPUT)/test_pids: cgroup_util.c -$(OUTPUT)/test_zswap: cgroup_util.c +$(OUTPUT)/test_core: $(LIBCGROUP_O) +$(OUTPUT)/test_cpu: $(LIBCGROUP_O) +$(OUTPUT)/test_cpuset: $(LIBCGROUP_O) +$(OUTPUT)/test_freezer: $(LIBCGROUP_O) +$(OUTPUT)/test_hugetlb_memcg: $(LIBCGROUP_O) +$(OUTPUT)/test_kill: $(LIBCGROUP_O) +$(OUTPUT)/test_kmem: $(LIBCGROUP_O) +$(OUTPUT)/test_memcontrol: $(LIBCGROUP_O) +$(OUTPUT)/test_pids: $(LIBCGROUP_O) +$(OUTPUT)/test_zswap: $(LIBCGROUP_O) diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/s= elftests/cgroup/lib/cgroup_util.c similarity index 99% rename from tools/testing/selftests/cgroup/cgroup_util.c rename to tools/testing/selftests/cgroup/lib/cgroup_util.c index 1e2d46636a0ca..f047d8adaec65 100644 --- a/tools/testing/selftests/cgroup/cgroup_util.c +++ b/tools/testing/selftests/cgroup/lib/cgroup_util.c @@ -17,7 +17,7 @@ #include =20 #include "cgroup_util.h" -#include "../clone3/clone3_selftests.h" +#include "../../clone3/clone3_selftests.h" =20 /* Returns read len on success, or -errno on failure. */ static ssize_t read_text(const char *path, char *buf, size_t max_len) diff --git a/tools/testing/selftests/cgroup/cgroup_util.h b/tools/testing/s= elftests/cgroup/lib/include/cgroup_util.h similarity index 99% rename from tools/testing/selftests/cgroup/cgroup_util.h rename to tools/testing/selftests/cgroup/lib/include/cgroup_util.h index 19b131ee77072..7a0441e5eb296 100644 --- a/tools/testing/selftests/cgroup/cgroup_util.h +++ b/tools/testing/selftests/cgroup/lib/include/cgroup_util.h @@ -2,9 +2,9 @@ #include #include =20 -#include "../kselftest.h" - +#ifndef PAGE_SIZE #define PAGE_SIZE 4096 +#endif =20 #define MB(x) (x << 20) =20 diff --git a/tools/testing/selftests/cgroup/lib/libcgroup.mk b/tools/testin= g/selftests/cgroup/lib/libcgroup.mk new file mode 100644 index 0000000000000..7a73007204c39 --- /dev/null +++ b/tools/testing/selftests/cgroup/lib/libcgroup.mk @@ -0,0 +1,19 @@ +CGROUP_DIR :=3D $(selfdir)/cgroup + +LIBCGROUP_C :=3D lib/cgroup_util.c + +LIBCGROUP_O :=3D $(patsubst %.c, $(OUTPUT)/%.o, $(LIBCGROUP_C)) + +LIBCGROUP_O_DIRS :=3D $(shell dirname $(LIBCGROUP_O) | uniq) + +CFLAGS +=3D -I$(CGROUP_DIR)/lib/include + +EXTRA_HDRS :=3D $(selfdir)/clone3/clone3_selftests.h + +$(LIBCGROUP_O_DIRS): + mkdir -p $@ + +$(LIBCGROUP_O): $(OUTPUT)/%.o : $(CGROUP_DIR)/%.c $(EXTRA_HDRS) $(LIBCGROU= P_O_DIRS) + $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ + +EXTRA_CLEAN +=3D $(LIBCGROUP_O) --=20 2.49.0.604.gff1f9ca942-goog