From 2996174021abec6019bd6a63c2630fab6c96e784 Mon Sep 17 00:00:00 2001
From: xiunianjun <1776527992@qq.com>
Date: Mon, 22 May 2023 16:40:43 +0800
Subject: [PATCH 1/7] =?UTF-8?q?test=EF=BC=9A=E5=A2=9E=E5=8A=A0simple=5Ftes?=
 =?UTF-8?q?t?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 tests/simple_test.cpp | 102 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)
 create mode 100644 tests/simple_test.cpp

diff --git a/tests/simple_test.cpp b/tests/simple_test.cpp
new file mode 100644
index 0000000..4c2be07
--- /dev/null
+++ b/tests/simple_test.cpp
@@ -0,0 +1,102 @@
+#include "../../../include/uapi/linux/sched.h"
+#include <stdio.h>
+#include <chrono> // for timing
+#include <vector>
+#include <assert.h>
+
+#include "../lib/cos_thread.h"
+
+const sched_param param{};
+
+class Timer {
+public:
+  Timer() { startTime_ = std::chrono::high_resolution_clock::now(); }
+  ~Timer() {
+    printf("The test takes %0.1f ms\n", std::chrono::high_resolution_clock::now() - startTime_);
+  }
+private:
+  std::chrono::high_resolution_clock::time_point startTime_;
+};
+
+void TestOne() {
+  printf("\nStarting one worker test...\n");
+  auto t = CosThread(CosThread::KernelSchedulerType::kExt, [] {
+    printf("thread begin...\n");
+    sleep(1);
+    printf("sleep over.\n");
+    
+    std::thread t2(
+        [] { assert(sched_getscheduler(0) == SCHED_EXT); });
+    t2.join();
+  });
+
+  t.WaitUntilInitComplete();
+  sched_setscheduler(t.tid(), SCHED_EXT, &param);
+  t.NotifyWork();
+  t.Join();
+  printf("\nFinish one worker test.\n");
+}
+
+
+void TestMany(int num_workers) {
+  printf("\nStarting many worker test...\n");
+  std::vector<std::unique_ptr<CosThread>> workers;
+
+  for (int i = 0; i < num_workers; i++) {
+    workers.emplace_back(new CosThread(CosThread::KernelSchedulerType::kExt, [] {
+          printf("working...\n");
+          sleep(1);
+    }));
+  }
+
+  for (auto& t : workers) {
+    t->WaitUntilInitComplete();
+    sched_setscheduler(t->tid(), SCHED_EXT, &param);
+    t->NotifyWork();
+  }
+  for (auto& t : workers) t->Join();
+  printf("\nFinish many worker test.\n");
+}
+
+void TestSwitchToCfs() {
+  printf("\nStarting switch-to-cfs test...\n");
+  CosThread t = CosThread(CosThread::KernelSchedulerType::kExt, [] {
+    printf("thread begin...\n");
+    sleep(1);
+    printf("sleep over.\n");
+
+    printf("now switch to CFS...\n");
+    assert(sched_getscheduler(0) == SCHED_EXT);
+
+    assert(sched_setscheduler(0, SCHED_NORMAL, &param) == 0);
+    assert(sched_getscheduler(0) == SCHED_NORMAL);
+    printf("switch to CFS successfully!\n");
+  });
+
+  t.WaitUntilInitComplete();
+  sched_setscheduler(t.tid(), SCHED_EXT, &param);
+  t.NotifyWork();
+  t.Join();
+  printf("\nFinish switch-to-cfs test.\n");
+}
+
+int main(){
+    {
+        printf("***TestOne***\n");
+        Timer t = Timer();
+        TestOne();
+    }
+
+    {
+        printf("***TestMany***\n");
+        Timer t = Timer();
+        TestMany(100);
+    }
+
+    {
+        printf("***TestSwitchToCfs***\n");
+        Timer t = Timer();
+        TestSwitchToCfs();
+    }
+    return 0;
+}
\ No newline at end of file
-- 
GitLab


From c494da8333a98773867d88593ed8f1e5aea506dd Mon Sep 17 00:00:00 2001
From: xiunianjun <1776527992@qq.com>
Date: Mon, 22 May 2023 16:43:15 +0800
Subject: [PATCH 2/7] =?UTF-8?q?refactor=EF=BC=9A=E5=B0=86=E5=8E=9F?=
 =?UTF-8?q?=E6=9C=AC=E9=99=90=E5=AE=9A=E7=B1=BB=E5=9E=8B=E4=B8=BAint32=5Ft?=
 =?UTF-8?q?=E7=9A=84data=E5=9F=9F=E8=BD=AC=E5=8C=96=E4=B8=BAstruct=20entry?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 client/cos_client.cpp | 20 +++++++-------------
 lib/hash.h            |  2 +-
 scx_sjf.c             | 23 ++++++++++++++---------
 scx_sjf_common.h      |  5 ++++-
 4 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/client/cos_client.cpp b/client/cos_client.cpp
index d811b80..a9ca2ac 100644
--- a/client/cos_client.cpp
+++ b/client/cos_client.cpp
@@ -1,6 +1,5 @@
 #include "../../../include/uapi/linux/sched.h"
 // #include <sched.h>
-#include <unistd.h>
 #include <vector>
 #include <stdio.h>
 #include <sys/mman.h>
@@ -8,38 +7,33 @@
 #include <sstream>   
 #include <cstring>
 #include <string.h>
-#include <functional>// for std::function
 // include order matters
 #include "../lib/cos_client.h"
+#include "../lib/cos.h"
 #include "../lib/cos_thread.h"
 
 #include "../lib/hash.h"
 
-
-// 模仿ghost那样,记录用户传进来的参数
 struct option{
     int worker_size;
-    int ddl;
 };
 
-// TODO:获取用户输入参数,填入struct option
 struct option get_options_from_args(int argc, char** argv){
-    return {1000, 10}; // 目前只创建一个worker线程
+    return {100};
 }
 
 int main(int argc, char** argv){
     struct option op = get_options_from_args(argc,argv);
     printf("%d:aaaaaaa laotan\n",getpid());
 
-    // TODO:修改路径;检查参数
     char buf[128];
     sprintf(buf,"/etc/cos/shm/shm_%d",getpid());
     int shm_fd = open(buf, O_RDWR | O_CREAT | O_TRUNC,0644);
-    struct entry* shm = (struct entry*)mmap(NULL, SHM_SIZE,PROT_READ|PROT_WRITE, MAP_SHARED,shm_fd,0);
+    void* shm = mmap(NULL, SHM_SIZE,PROT_READ|PROT_WRITE, MAP_SHARED,shm_fd,0);
     ftruncate(shm_fd, SHM_SIZE); 
     memset(shm,0,SHM_SIZE);
 
-    LFHashTable<int32_t> hashtable((void*)shm, SHM_SIZE, 0);
+    LFHashTable<struct entry> hashtable(shm, SHM_SIZE, 0);
     std::vector<std::unique_ptr<CosThread>> workers;
     for(int i=0;i<op.worker_size;i++){
         workers.emplace_back(new CosThread(CosThread::KernelSchedulerType::kExt, []{
@@ -49,16 +43,16 @@ int main(int argc, char** argv){
             }
         }));
     }
-    // 填信息、设置调度类、唤醒
+
     for (auto& t : workers) {
         t->WaitUntilInitComplete();
         int tid = t->tid();
-        hashtable.Add(tid, tid);
+        hashtable.Add(tid, {tid});
+
         struct sched_param param = { .sched_priority = 0 }; 
         sched_setscheduler(tid, SCHED_EXT, &param); 
 
         printf("%d:唤醒了%d\n",getpid(),tid);
-        // 唤醒
         t->NotifyWork();
     }
 
diff --git a/lib/hash.h b/lib/hash.h
index 4cd6cc5..82b3254 100644
--- a/lib/hash.h
+++ b/lib/hash.h
@@ -49,7 +49,7 @@ public:
         assert(key != 0);
         for (int idx = hash(key); ; idx = (idx + 1) % capacity_) {
             if (table_[idx].key == 0) {
-                return 0;
+                return {};
             }
             if (table_[idx].key != key) {
                 continue;
diff --git a/scx_sjf.c b/scx_sjf.c
index 3ba6036..1d34835 100644
--- a/scx_sjf.c
+++ b/scx_sjf.c
@@ -187,10 +187,8 @@ static int vruntime_enqueue(const struct scx_userland_enqueued_task *bpf_task)
 
 #include <fcntl.h> // for O_RDWR and open
 
-#define SHM_SIZE 4096
-
-
-std::map<__s32, LFHashTable<int32_t>> tgid2hashtable; 
+// std::map<__s32, LFHashTable<int32_t>> tgid2hashtable; 
+std::map<__s32, LFHashTable<struct entry>> tgid2hashtable; 
 
 static void drain_enqueued_map(void)
 {
@@ -202,7 +200,7 @@ static void drain_enqueued_map(void)
 		}	
 
 
-		/* do scheduler */
+		/* do schedule */
 		__s32 tgid = task.tgid; 
 
 		if(tgid != getpid()){
@@ -212,14 +210,21 @@ static void drain_enqueued_map(void)
 				char buf[128];
 				sprintf(buf, "/etc/cos/shm/shm_%d", tgid);
 				int shm_fd = open(buf, O_RDWR);
-				void* shm = (struct entry*)mmap(NULL, SHM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0);
-				tgid2hashtable[tgid] = LFHashTable<int32_t>((void*)shm, SHM_SIZE, 0);
+				void* shm = mmap(NULL, SHM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0);
+				if(shm == MAP_FAILED) { // the client doesn't use share memory
+					goto enqueue;
+				}
+				tgid2hashtable[tgid] = LFHashTable<struct entry>(shm, SHM_SIZE, 0);
 			}
 
-			task.ddl = tgid2hashtable[tgid].Get(task.pid);
-			printf("thread %d ddl=%d\n", task.pid, task.ddl);
+			struct entry tmp = tgid2hashtable[tgid].Get(task.pid);
+			memcpy(&(task.data), &tmp, sizeof(struct entry));
+			// task.ddl = tgid2hashtable[tgid].Get(task.pid);
+			printf("thread %d ddl=%d\n", task.pid, task.data.ddl);
 
 		}
+
+		enqueue:
 		err = vruntime_enqueue(&task);
 		if (err) {
 			fprintf(stderr, "Failed to enqueue task %d: %s\n",
diff --git a/scx_sjf_common.h b/scx_sjf_common.h
index 0d7b20c..6c7fa3d 100644
--- a/scx_sjf_common.h
+++ b/scx_sjf_common.h
@@ -6,6 +6,9 @@
 
 #define USERLAND_MAX_TASKS 60000
 
+#include "lib/cos_client.h"
+#include "lib/cos.h"
+
 /*
  * An instance of a task that has been enqueued by the kernel for consumption
  * by a user space global scheduler thread.
@@ -18,7 +21,7 @@ struct scx_userland_enqueued_task {
 
 	/* 新增 */
 	__s32 tgid; // 代表该线程所属的进程的pid,在bpf程序的enqueue_task_in_user_space中被填写
-	int ddl;
+	struct entry data;
 };
 
 #endif  // __SCX_USERLAND_COMMON_H
-- 
GitLab


From 268f02e863f4f3b385cee401f2254b88dc328ce3 Mon Sep 17 00:00:00 2001
From: xiunianjun <1776527992@qq.com>
Date: Mon, 22 May 2023 16:44:24 +0800
Subject: [PATCH 3/7] =?UTF-8?q?refactor=EF=BC=9A=E4=BF=AE=E6=94=B9?=
 =?UTF-8?q?=E5=A4=B4=E6=96=87=E4=BB=B6=E4=BE=9D=E8=B5=96=E7=BB=93=E6=9E=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/cos.h        | 8 ++------
 lib/cos_thread.h | 7 +++++--
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/lib/cos.h b/lib/cos.h
index 22772d3..1e33484 100644
--- a/lib/cos.h
+++ b/lib/cos.h
@@ -1,11 +1,7 @@
-#include <thread>
-
 struct entry;
 
 //每块shm的大小
 #define SHM_SIZE 4096
 
-// shm的最大entry数
-#define MAX_ENTRY_NUMS SHM_SIZE / sizeof(struct entry)
-
-
+// // shm的最大entry数
+// #define MAX_ENTRY_NUMS SHM_SIZE / sizeof(struct entry)
\ No newline at end of file
diff --git a/lib/cos_thread.h b/lib/cos_thread.h
index 41f7e3a..239a167 100644
--- a/lib/cos_thread.h
+++ b/lib/cos_thread.h
@@ -1,4 +1,7 @@
-#include "cos.h"
+#include <thread>
+#include <functional>// for std::function
+#include <unistd.h>
+
 class CosThread {
  public:
   // The kernel scheduling class to run the thread in.
@@ -9,7 +12,7 @@ class CosThread {
     kExt,
   };
 
-  explicit CosThread(KernelSchedulerType ksched, std::function<void()>& work) {
+  explicit CosThread(KernelSchedulerType ksched, std::function<void()> work) {
     work_start_ = false;
     ksched_ = ksched;
     thread_ = std::thread([this, w = std::move(work)] {
-- 
GitLab


From 80b06016dd61a271d63e67b375a00b40739ccfe3 Mon Sep 17 00:00:00 2001
From: xiunianjun <1776527992@qq.com>
Date: Mon, 22 May 2023 16:45:03 +0800
Subject: [PATCH 4/7] =?UTF-8?q?feat=EF=BC=9A=E4=BF=AE=E6=94=B9makefile?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Makefile        | 2 +-
 client/Makefile | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 86959bf..03a48a8 100644
--- a/Makefile
+++ b/Makefile
@@ -181,7 +181,7 @@ clean:
 	rm -f scx_sjf
 
 install:
-	sudo mkdir /etc/cos/shm
+	sudo mkdir -p /etc/cos/shm
 
 .PHONY: all clean install
 
diff --git a/client/Makefile b/client/Makefile
index 22f6a6c..cd590e4 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -11,9 +11,12 @@ all: $(TARGET)
 $(TARGET): $(OBJS)
 	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
 
+cos_client: cos_client.o
+	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
+
 %.o: %.cpp
 	$(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@
 
 clean:
-	rm -rf $(TARGET) $(OBJS) shm*
+	rm -rf $(TARGET) cos_client cos_client.o $(OBJS) shm*
 
-- 
GitLab


From 1ad0198843c15985fa906fea43864f3870df8a95 Mon Sep 17 00:00:00 2001
From: xiunianjun <1776527992@qq.com>
Date: Mon, 22 May 2023 16:49:17 +0800
Subject: [PATCH 5/7] =?UTF-8?q?style=EF=BC=9A=E5=88=A0=E9=99=A4=E9=83=A8?=
 =?UTF-8?q?=E5=88=86=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 scx_sjf.bpf.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/scx_sjf.bpf.c b/scx_sjf.bpf.c
index 7c514fa..056712b 100644
--- a/scx_sjf.bpf.c
+++ b/scx_sjf.bpf.c
@@ -85,15 +85,6 @@ static bool is_usersched_task(const struct task_struct *p)
 
 static bool keep_in_kernel(const struct task_struct *p)
 {
-	// 结构体task_struct中的nr_cpus_allowed成员表示可以在哪些CPU上运行当前任务
-	// woc,6666666
-	// num_possible_cpus如果是二的幂次,那么这就相当于一个有效性的判定
-	// 比如说num_possible_cpus为64,也即0100 0000
-	// 也即本机共有6个CPU!
-	// 那么nr_cpus_allowed这个位图的合法值就为形如11 1100 、 00 1010这种,都必须<num_possible_cpus
-	// 也就是说,这玩意相当于把CPU分为了两个类别,这两个类别分别由kernel和userspace掌管
-	// 如果p能跑的cpu全在kernel类中,那么p就必须在kernel中;
-	// 否则,p就可以进入userland scheduler被调度执行!!
 	return p->nr_cpus_allowed < num_possible_cpus;
 }
 
@@ -115,7 +106,7 @@ static struct task_struct *usersched_task(void)
 s32 BPF_STRUCT_OPS(userland_select_cpu, struct task_struct *p,
 		   s32 prev_cpu, u64 wake_flags)
 {
-	if (keep_in_kernel(p)) {// 如果p必须在kernel中被调度,那么就给它认真选一下
+	if (keep_in_kernel(p)) {
 		s32 cpu;
 		struct task_ctx *tctx;
 
@@ -177,15 +168,9 @@ static void enqueue_task_in_user_space(struct task_struct *p, u64 enq_flags)
 	}
 }
 
-
-// 在task需要被enqueue到bpf scheduler时调用
-// 那么,里面的逻辑应该是直接把task放入自己的enqueued队列中,就是这么简单
-// 因为userland已经在持续检查bpf schduler的enqueued队列了
 void BPF_STRUCT_OPS(userland_enqueue, struct task_struct *p, u64 enq_flags)
 {
 	if (keep_in_kernel(p)) {
-		// 如果p必须在kernel而非userland中被调用
-		// 选一下GLOBAL或者LOCAL队列调用
 		u64 dsq_id = SCX_DSQ_GLOBAL;
 		struct task_ctx *tctx;
 
@@ -203,13 +188,11 @@ void BPF_STRUCT_OPS(userland_enqueue, struct task_struct *p, u64 enq_flags)
 
 		if (tctx->force_local)
 			dsq_id = SCX_DSQ_LOCAL;
-		tctx->force_local = false;// 重置标记位
+		tctx->force_local = false;
 		scx_bpf_dispatch(p, dsq_id, SCX_SLICE_DFL, enq_flags);
 		__sync_fetch_and_add(&nr_kernel_enqueues, 1);
 		return;
 	} else if (!is_usersched_task(p)) {
-		// 如果p不是userland scheduler,那么就把p放入userland scheduler的调度队列中
-		
 		enqueue_task_in_user_space(p, enq_flags);
 	}
 }
-- 
GitLab


From d8f296a06758dae1d99d85391ce54c5322ae7073 Mon Sep 17 00:00:00 2001
From: xiunianjun <1776527992@qq.com>
Date: Mon, 22 May 2023 17:06:49 +0800
Subject: [PATCH 6/7] fq

---
 sched/Makefile                             | 194 +++++++++++++++++++++
 scx_sjf.bpf.c => sched/scx_sjf.bpf.c       |   4 +-
 scx_sjf.c => sched/scx_sjf.c               |   0
 scx_sjf_common.h => sched/scx_sjf_common.h |   0
 4 files changed, 196 insertions(+), 2 deletions(-)
 create mode 100644 sched/Makefile
 rename scx_sjf.bpf.c => sched/scx_sjf.bpf.c (99%)
 rename scx_sjf.c => sched/scx_sjf.c (100%)
 rename scx_sjf_common.h => sched/scx_sjf_common.h (100%)

diff --git a/sched/Makefile b/sched/Makefile
new file mode 100644
index 0000000..b1da210
--- /dev/null
+++ b/sched/Makefile
@@ -0,0 +1,194 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022 Meta Platforms, Inc. and affiliates.
+include ../../build/Build.include
+include ../../scripts/Makefile.arch
+include ../../scripts/Makefile.include
+
+ifneq ($(LLVM),)
+ifneq ($(filter %/,$(LLVM)),)
+LLVM_PREFIX := $(LLVM)
+else ifneq ($(filter -%,$(LLVM)),)
+LLVM_SUFFIX := $(LLVM)
+endif
+
+CLANG_TARGET_FLAGS_arm          := arm-linux-gnueabi
+CLANG_TARGET_FLAGS_arm64        := aarch64-linux-gnu
+CLANG_TARGET_FLAGS_hexagon      := hexagon-linux-musl
+CLANG_TARGET_FLAGS_m68k         := m68k-linux-gnu
+CLANG_TARGET_FLAGS_mips         := mipsel-linux-gnu
+CLANG_TARGET_FLAGS_powerpc      := powerpc64le-linux-gnu
+CLANG_TARGET_FLAGS_riscv        := riscv64-linux-gnu
+CLANG_TARGET_FLAGS_s390         := s390x-linux-gnu
+CLANG_TARGET_FLAGS_x86          := x86_64-linux-gnu
+CLANG_TARGET_FLAGS              := $(CLANG_TARGET_FLAGS_$(ARCH))
+
+ifeq ($(CROSS_COMPILE),)
+ifeq ($(CLANG_TARGET_FLAGS),)
+$(error Specify CROSS_COMPILE or add '--target=' option to lib.mk
+else
+CLANG_FLAGS     += --target=$(CLANG_TARGET_FLAGS)
+endif # CLANG_TARGET_FLAGS
+else
+CLANG_FLAGS     += --target=$(notdir $(CROSS_COMPILE:%-=%))
+endif # CROSS_COMPILE
+
+CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX) $(CLANG_FLAGS) -fintegrated-as
+else
+CC := $(CROSS_COMPILE)g++
+endif # LLVM
+
+CURDIR := $(abspath .)
+TOOLSDIR := $(abspath ../..)
+LIBDIR := $(TOOLSDIR)/lib
+COS_LIBDIR := $(CURDIR)/lib
+BPFDIR := $(LIBDIR)/bpf
+TOOLSINCDIR := $(TOOLSDIR)/include
+BPFTOOLDIR := $(TOOLSDIR)/bpf/bpftool
+APIDIR := $(TOOLSINCDIR)/uapi
+GENDIR := $(abspath ../../../include/generated)
+GENHDR := $(GENDIR)/autoconf.h
+LLVM_INCLUDE := /home/shootfirst/llvm-project/build/lib/clang/17/include/
+
+# SCRATCH_DIR := $(CURDIR)/tools
+SCRATCH_DIR := ../tools
+BUILD_DIR := $(SCRATCH_DIR)/build
+INCLUDE_DIR := $(SCRATCH_DIR)/include
+BPFOBJ_DIR := $(BUILD_DIR)/libbpf
+BPFOBJ := $(BPFOBJ_DIR)/libbpf.a
+ifneq ($(CROSS_COMPILE),)
+HOST_BUILD_DIR		:= $(BUILD_DIR)/host
+HOST_SCRATCH_DIR	:= host-tools
+HOST_INCLUDE_DIR	:= $(HOST_SCRATCH_DIR)/include
+else
+HOST_BUILD_DIR		:= $(BUILD_DIR)
+HOST_SCRATCH_DIR	:= $(SCRATCH_DIR)
+HOST_INCLUDE_DIR	:= $(INCLUDE_DIR)
+endif
+HOST_BPFOBJ := $(HOST_BUILD_DIR)/libbpf/libbpf.a
+RESOLVE_BTFIDS := $(HOST_BUILD_DIR)/resolve_btfids/resolve_btfids
+DEFAULT_BPFTOOL := $(HOST_SCRATCH_DIR)/sbin/bpftool
+
+VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux)					\
+		     $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux)		\
+		     ../../../vmlinux						\
+		     /sys/kernel/btf/vmlinux					\
+		     /boot/vmlinux-$(shell uname -r)
+VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS))))
+ifeq ($(VMLINUX_BTF),)
+$(error Cannot find a vmlinux for VMLINUX_BTF at any of "$(VMLINUX_BTF_PATHS)")
+endif
+
+BPFTOOL ?= $(DEFAULT_BPFTOOL)
+
+ifneq ($(wildcard $(GENHDR)),)
+  GENFLAGS := -DHAVE_GENHDR
+endif
+
+CFLAGS += -g -O2 -rdynamic -pthread -std=c++11 -Wall -Werror $(GENFLAGS)			\
+	  -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR)			\
+	  -I$(TOOLSINCDIR) -I$(APIDIR) -I$(COS_LIBDIR)
+
+CARGOFLAGS := --release
+
+# Silence some warnings when compiled with clang
+ifneq ($(LLVM),)
+CFLAGS += -Wno-unused-command-line-argument
+endif
+
+LDFLAGS = -lelf -lz -lpthread
+
+IS_LITTLE_ENDIAN = $(shell $(CC) -dM -E - </dev/null |				\
+			grep 'define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__')
+
+# Get Clang's default includes on this system, as opposed to those seen by
+# '-target bpf'. This fixes "missing" files on some architectures/distros,
+# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc.
+#
+# Use '-idirafter': Don't interfere with include mechanics except where the
+# build would have failed anyways.
+define get_sys_includes
+$(shell $(1) -v -E - </dev/null 2>&1 \
+	| sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \
+$(shell $(1) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}')
+endef
+
+BPF_CFLAGS = -g -D__TARGET_ARCH_$(SRCARCH)					\
+	     $(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian)		\
+	     -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR) -I$(LLVM_INCLUDE)				\
+	     -I../../../include							\
+	     $(call get_sys_includes,$(CLANG))					\
+	     -Wall -Wno-compare-distinct-pointer-types				\
+	     -O2 -mcpu=v3
+
+all: scx_sjf
+
+# sort removes libbpf duplicates when not cross-building
+MAKE_DIRS := $(sort $(BUILD_DIR)/libbpf $(HOST_BUILD_DIR)/libbpf		\
+	       $(HOST_BUILD_DIR)/bpftool $(HOST_BUILD_DIR)/resolve_btfids	\
+	       $(INCLUDE_DIR))
+
+$(MAKE_DIRS):
+	$(call msg,MKDIR,,$@)
+	$(Q)mkdir -p $@
+
+$(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile)			\
+	   $(APIDIR)/linux/bpf.h						\
+	   | $(BUILD_DIR)/libbpf
+	$(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(BUILD_DIR)/libbpf/	\
+		    EXTRA_CFLAGS='-g -O0 -fPIC'					\
+		    DESTDIR=$(SCRATCH_DIR) prefix= all install_headers
+
+$(DEFAULT_BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile)	\
+		    $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/bpftool
+	$(Q)$(MAKE) $(submake_extras)  -C $(BPFTOOLDIR)				\
+		    ARCH= CROSS_COMPILE= CC=$(HOSTCC) LD=$(HOSTLD)		\
+		    EXTRA_CFLAGS='-g -O0'					\
+		    OUTPUT=$(HOST_BUILD_DIR)/bpftool/				\
+		    LIBBPF_OUTPUT=$(HOST_BUILD_DIR)/libbpf/			\
+		    LIBBPF_DESTDIR=$(HOST_SCRATCH_DIR)/				\
+		    prefix= DESTDIR=$(HOST_SCRATCH_DIR)/ install-bin
+
+$(INCLUDE_DIR)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL) | $(INCLUDE_DIR)
+ifeq ($(VMLINUX_H),)
+	$(call msg,GEN,,$@)
+	$(Q)$(BPFTOOL) btf dump file $(VMLINUX_BTF) format c > $@
+else
+	$(call msg,CP,,$@)
+	$(Q)cp "$(VMLINUX_H)" $@
+endif
+
+%.bpf.o: %.bpf.c $(INCLUDE_DIR)/vmlinux.h scx_common.bpf.h user_exit_info.h	\
+	| $(BPFOBJ)
+	$(call msg,CLNG-BPF,,$@)
+	$(Q)$(CLANG) $(BPF_CFLAGS) -target bpf -c $< -o $@
+
+%.skel.h: %.bpf.o $(BPFTOOL)
+	$(call msg,GEN-SKEL,,$@)
+	$(Q)$(BPFTOOL) gen object $(<:.o=.linked1.o) $<
+	$(Q)$(BPFTOOL) gen object $(<:.o=.linked2.o) $(<:.o=.linked1.o)
+	$(Q)$(BPFTOOL) gen object $(<:.o=.linked3.o) $(<:.o=.linked2.o)
+	$(Q)diff $(<:.o=.linked2.o) $(<:.o=.linked3.o)
+	$(Q)$(BPFTOOL) gen skeleton $(<:.o=.linked3.o) name $(<:.bpf.o=) > $@
+	$(Q)$(BPFTOOL) gen subskeleton $(<:.o=.linked3.o) name $(<:.bpf.o=) > $(@:.skel.h=.subskel.h)
+
+scx_sjf: scx_sjf.c scx_sjf.skel.h	\
+		      scx_sjf_common.h user_exit_info.h
+	$(CC) $(CFLAGS) -c $< -o $@.o
+	$(CC) -o $@ $@.o $(HOST_BPFOBJ) $(LDFLAGS)
+
+
+clean:
+	rm -rf $(SCRATCH_DIR) $(HOST_SCRATCH_DIR)
+	rm -f *.o *.bpf.o *.skel.h *.subskel.h
+	rm -f scx_sjf
+
+install:
+	sudo mkdir -p /etc/cos/shm
+
+.PHONY: all clean install
+
+# delete failed targets
+.DELETE_ON_ERROR:
+
+# keep intermediate (.skel.h, .bpf.o, etc) targets
+.SECONDARY:
diff --git a/scx_sjf.bpf.c b/sched/scx_sjf.bpf.c
similarity index 99%
rename from scx_sjf.bpf.c
rename to sched/scx_sjf.bpf.c
index 056712b..cd2f741 100644
--- a/scx_sjf.bpf.c
+++ b/sched/scx_sjf.bpf.c
@@ -21,8 +21,8 @@
  * Copyright (c) 2022 David Vernet <dvernet@meta.com>
  */
 #include <string.h>
-#include "scx_common.bpf.h"
-#include "scx_sjf_common.h"
+#include "../scx_common.bpf.h"
+#include "../scx_sjf_common.h"
 
 char _license[] SEC("license") = "GPL";
 
diff --git a/scx_sjf.c b/sched/scx_sjf.c
similarity index 100%
rename from scx_sjf.c
rename to sched/scx_sjf.c
diff --git a/scx_sjf_common.h b/sched/scx_sjf_common.h
similarity index 100%
rename from scx_sjf_common.h
rename to sched/scx_sjf_common.h
-- 
GitLab


From 8ad313877d5d0d26e99bc9063fe70d22c9e31e23 Mon Sep 17 00:00:00 2001
From: xiunianjun <1776527992@qq.com>
Date: Mon, 22 May 2023 17:45:04 +0800
Subject: [PATCH 7/7] =?UTF-8?q?feat=EF=BC=9A=E5=B0=86scheduler=E6=95=B4?=
 =?UTF-8?q?=E7=90=86=E8=BF=9B=E5=85=A5sched=E7=9B=AE=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Makefile                                   | 192 ---------------------
 sched/Makefile                             |  13 +-
 scx_common.bpf.h => sched/scx_common.bpf.h |   0
 sched/{ => sjf}/scx_sjf.bpf.c              |   2 +-
 sched/{ => sjf}/scx_sjf.c                  |   4 +-
 sched/{ => sjf}/scx_sjf_common.h           |   4 +-
 user_exit_info.h => sched/user_exit_info.h |   0
 7 files changed, 11 insertions(+), 204 deletions(-)
 delete mode 100644 Makefile
 rename scx_common.bpf.h => sched/scx_common.bpf.h (100%)
 rename sched/{ => sjf}/scx_sjf.bpf.c (99%)
 rename sched/{ => sjf}/scx_sjf.c (99%)
 rename sched/{ => sjf}/scx_sjf_common.h (91%)
 rename user_exit_info.h => sched/user_exit_info.h (100%)

diff --git a/Makefile b/Makefile
deleted file mode 100644
index 03a48a8..0000000
--- a/Makefile
+++ /dev/null
@@ -1,192 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-# Copyright (c) 2022 Meta Platforms, Inc. and affiliates.
-include ../build/Build.include
-include ../scripts/Makefile.arch
-include ../scripts/Makefile.include
-
-ifneq ($(LLVM),)
-ifneq ($(filter %/,$(LLVM)),)
-LLVM_PREFIX := $(LLVM)
-else ifneq ($(filter -%,$(LLVM)),)
-LLVM_SUFFIX := $(LLVM)
-endif
-
-CLANG_TARGET_FLAGS_arm          := arm-linux-gnueabi
-CLANG_TARGET_FLAGS_arm64        := aarch64-linux-gnu
-CLANG_TARGET_FLAGS_hexagon      := hexagon-linux-musl
-CLANG_TARGET_FLAGS_m68k         := m68k-linux-gnu
-CLANG_TARGET_FLAGS_mips         := mipsel-linux-gnu
-CLANG_TARGET_FLAGS_powerpc      := powerpc64le-linux-gnu
-CLANG_TARGET_FLAGS_riscv        := riscv64-linux-gnu
-CLANG_TARGET_FLAGS_s390         := s390x-linux-gnu
-CLANG_TARGET_FLAGS_x86          := x86_64-linux-gnu
-CLANG_TARGET_FLAGS              := $(CLANG_TARGET_FLAGS_$(ARCH))
-
-ifeq ($(CROSS_COMPILE),)
-ifeq ($(CLANG_TARGET_FLAGS),)
-$(error Specify CROSS_COMPILE or add '--target=' option to lib.mk
-else
-CLANG_FLAGS     += --target=$(CLANG_TARGET_FLAGS)
-endif # CLANG_TARGET_FLAGS
-else
-CLANG_FLAGS     += --target=$(notdir $(CROSS_COMPILE:%-=%))
-endif # CROSS_COMPILE
-
-CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX) $(CLANG_FLAGS) -fintegrated-as
-else
-CC := $(CROSS_COMPILE)g++
-endif # LLVM
-
-CURDIR := $(abspath .)
-TOOLSDIR := $(abspath ..)
-LIBDIR := $(TOOLSDIR)/lib
-BPFDIR := $(LIBDIR)/bpf
-TOOLSINCDIR := $(TOOLSDIR)/include
-BPFTOOLDIR := $(TOOLSDIR)/bpf/bpftool
-APIDIR := $(TOOLSINCDIR)/uapi
-GENDIR := $(abspath ../../include/generated)
-GENHDR := $(GENDIR)/autoconf.h
-LLVM_INCLUDE := /home/shootfirst/llvm-project/build/lib/clang/17/include/
-
-SCRATCH_DIR := $(CURDIR)/tools
-BUILD_DIR := $(SCRATCH_DIR)/build
-INCLUDE_DIR := $(SCRATCH_DIR)/include
-BPFOBJ_DIR := $(BUILD_DIR)/libbpf
-BPFOBJ := $(BPFOBJ_DIR)/libbpf.a
-ifneq ($(CROSS_COMPILE),)
-HOST_BUILD_DIR		:= $(BUILD_DIR)/host
-HOST_SCRATCH_DIR	:= host-tools
-HOST_INCLUDE_DIR	:= $(HOST_SCRATCH_DIR)/include
-else
-HOST_BUILD_DIR		:= $(BUILD_DIR)
-HOST_SCRATCH_DIR	:= $(SCRATCH_DIR)
-HOST_INCLUDE_DIR	:= $(INCLUDE_DIR)
-endif
-HOST_BPFOBJ := $(HOST_BUILD_DIR)/libbpf/libbpf.a
-RESOLVE_BTFIDS := $(HOST_BUILD_DIR)/resolve_btfids/resolve_btfids
-DEFAULT_BPFTOOL := $(HOST_SCRATCH_DIR)/sbin/bpftool
-
-VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux)					\
-		     $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux)		\
-		     ../../vmlinux						\
-		     /sys/kernel/btf/vmlinux					\
-		     /boot/vmlinux-$(shell uname -r)
-VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS))))
-ifeq ($(VMLINUX_BTF),)
-$(error Cannot find a vmlinux for VMLINUX_BTF at any of "$(VMLINUX_BTF_PATHS)")
-endif
-
-BPFTOOL ?= $(DEFAULT_BPFTOOL)
-
-ifneq ($(wildcard $(GENHDR)),)
-  GENFLAGS := -DHAVE_GENHDR
-endif
-
-CFLAGS += -g -O2 -rdynamic -pthread -std=c++11 -Wall -Werror $(GENFLAGS)			\
-	  -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR)				\
-	  -I$(TOOLSINCDIR) -I$(APIDIR)
-
-CARGOFLAGS := --release
-
-# Silence some warnings when compiled with clang
-ifneq ($(LLVM),)
-CFLAGS += -Wno-unused-command-line-argument
-endif
-
-LDFLAGS = -lelf -lz -lpthread
-
-IS_LITTLE_ENDIAN = $(shell $(CC) -dM -E - </dev/null |				\
-			grep 'define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__')
-
-# Get Clang's default includes on this system, as opposed to those seen by
-# '-target bpf'. This fixes "missing" files on some architectures/distros,
-# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc.
-#
-# Use '-idirafter': Don't interfere with include mechanics except where the
-# build would have failed anyways.
-define get_sys_includes
-$(shell $(1) -v -E - </dev/null 2>&1 \
-	| sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \
-$(shell $(1) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}')
-endef
-
-BPF_CFLAGS = -g -D__TARGET_ARCH_$(SRCARCH)					\
-	     $(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian)		\
-	     -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR) -I$(LLVM_INCLUDE)				\
-	     -I../../include							\
-	     $(call get_sys_includes,$(CLANG))					\
-	     -Wall -Wno-compare-distinct-pointer-types				\
-	     -O2 -mcpu=v3
-
-all: scx_sjf
-
-# sort removes libbpf duplicates when not cross-building
-MAKE_DIRS := $(sort $(BUILD_DIR)/libbpf $(HOST_BUILD_DIR)/libbpf		\
-	       $(HOST_BUILD_DIR)/bpftool $(HOST_BUILD_DIR)/resolve_btfids	\
-	       $(INCLUDE_DIR))
-
-$(MAKE_DIRS):
-	$(call msg,MKDIR,,$@)
-	$(Q)mkdir -p $@
-
-$(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile)			\
-	   $(APIDIR)/linux/bpf.h						\
-	   | $(BUILD_DIR)/libbpf
-	$(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(BUILD_DIR)/libbpf/	\
-		    EXTRA_CFLAGS='-g -O0 -fPIC'					\
-		    DESTDIR=$(SCRATCH_DIR) prefix= all install_headers
-
-$(DEFAULT_BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile)	\
-		    $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/bpftool
-	$(Q)$(MAKE) $(submake_extras)  -C $(BPFTOOLDIR)				\
-		    ARCH= CROSS_COMPILE= CC=$(HOSTCC) LD=$(HOSTLD)		\
-		    EXTRA_CFLAGS='-g -O0'					\
-		    OUTPUT=$(HOST_BUILD_DIR)/bpftool/				\
-		    LIBBPF_OUTPUT=$(HOST_BUILD_DIR)/libbpf/			\
-		    LIBBPF_DESTDIR=$(HOST_SCRATCH_DIR)/				\
-		    prefix= DESTDIR=$(HOST_SCRATCH_DIR)/ install-bin
-
-$(INCLUDE_DIR)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL) | $(INCLUDE_DIR)
-ifeq ($(VMLINUX_H),)
-	$(call msg,GEN,,$@)
-	$(Q)$(BPFTOOL) btf dump file $(VMLINUX_BTF) format c > $@
-else
-	$(call msg,CP,,$@)
-	$(Q)cp "$(VMLINUX_H)" $@
-endif
-
-%.bpf.o: %.bpf.c $(INCLUDE_DIR)/vmlinux.h scx_common.bpf.h user_exit_info.h	\
-	| $(BPFOBJ)
-	$(call msg,CLNG-BPF,,$@)
-	$(Q)$(CLANG) $(BPF_CFLAGS) -target bpf -c $< -o $@
-
-%.skel.h: %.bpf.o $(BPFTOOL)
-	$(call msg,GEN-SKEL,,$@)
-	$(Q)$(BPFTOOL) gen object $(<:.o=.linked1.o) $<
-	$(Q)$(BPFTOOL) gen object $(<:.o=.linked2.o) $(<:.o=.linked1.o)
-	$(Q)$(BPFTOOL) gen object $(<:.o=.linked3.o) $(<:.o=.linked2.o)
-	$(Q)diff $(<:.o=.linked2.o) $(<:.o=.linked3.o)
-	$(Q)$(BPFTOOL) gen skeleton $(<:.o=.linked3.o) name $(<:.bpf.o=) > $@
-	$(Q)$(BPFTOOL) gen subskeleton $(<:.o=.linked3.o) name $(<:.bpf.o=) > $(@:.skel.h=.subskel.h)
-
-scx_sjf: scx_sjf.c scx_sjf.skel.h	\
-		      scx_sjf_common.h user_exit_info.h
-	$(CC) $(CFLAGS) -c $< -o $@.o
-	$(CC) -o $@ $@.o $(HOST_BPFOBJ) $(LDFLAGS)
-
-
-clean:
-	rm -rf $(SCRATCH_DIR) $(HOST_SCRATCH_DIR)
-	rm -f *.o *.bpf.o *.skel.h *.subskel.h
-	rm -f scx_sjf
-
-install:
-	sudo mkdir -p /etc/cos/shm
-
-.PHONY: all clean install
-
-# delete failed targets
-.DELETE_ON_ERROR:
-
-# keep intermediate (.skel.h, .bpf.o, etc) targets
-.SECONDARY:
diff --git a/sched/Makefile b/sched/Makefile
index b1da210..e8fc90f 100644
--- a/sched/Makefile
+++ b/sched/Makefile
@@ -49,8 +49,7 @@ GENDIR := $(abspath ../../../include/generated)
 GENHDR := $(GENDIR)/autoconf.h
 LLVM_INCLUDE := /home/shootfirst/llvm-project/build/lib/clang/17/include/
 
-# SCRATCH_DIR := $(CURDIR)/tools
-SCRATCH_DIR := ../tools
+SCRATCH_DIR := $(CURDIR)/tools
 BUILD_DIR := $(SCRATCH_DIR)/build
 INCLUDE_DIR := $(SCRATCH_DIR)/include
 BPFOBJ_DIR := $(BUILD_DIR)/libbpf
@@ -168,18 +167,18 @@ endif
 	$(Q)$(BPFTOOL) gen object $(<:.o=.linked2.o) $(<:.o=.linked1.o)
 	$(Q)$(BPFTOOL) gen object $(<:.o=.linked3.o) $(<:.o=.linked2.o)
 	$(Q)diff $(<:.o=.linked2.o) $(<:.o=.linked3.o)
-	$(Q)$(BPFTOOL) gen skeleton $(<:.o=.linked3.o) name $(<:.bpf.o=) > $@
-	$(Q)$(BPFTOOL) gen subskeleton $(<:.o=.linked3.o) name $(<:.bpf.o=) > $(@:.skel.h=.subskel.h)
+	$(Q)$(BPFTOOL) gen skeleton $(<:.o=.linked3.o) name $(notdir $(<:.bpf.o=)) > $@
+	$(Q)$(BPFTOOL) gen subskeleton $(<:.o=.linked3.o) name $(notdir $(<:.bpf.o=)) > $(@:.skel.h=.subskel.h)
 
-scx_sjf: scx_sjf.c scx_sjf.skel.h	\
-		      scx_sjf_common.h user_exit_info.h
+scx_sjf: $(CURDIR)/sjf/scx_sjf.c $(CURDIR)/sjf/scx_sjf.skel.h	\
+		      $(CURDIR)/sjf/scx_sjf_common.h user_exit_info.h
 	$(CC) $(CFLAGS) -c $< -o $@.o
 	$(CC) -o $@ $@.o $(HOST_BPFOBJ) $(LDFLAGS)
 
 
 clean:
 	rm -rf $(SCRATCH_DIR) $(HOST_SCRATCH_DIR)
-	rm -f *.o *.bpf.o *.skel.h *.subskel.h
+	rm -f sjf/*.o sjf/*.bpf.o sjf/*.skel.h sjf/*.subskel.h *.o
 	rm -f scx_sjf
 
 install:
diff --git a/scx_common.bpf.h b/sched/scx_common.bpf.h
similarity index 100%
rename from scx_common.bpf.h
rename to sched/scx_common.bpf.h
diff --git a/sched/scx_sjf.bpf.c b/sched/sjf/scx_sjf.bpf.c
similarity index 99%
rename from sched/scx_sjf.bpf.c
rename to sched/sjf/scx_sjf.bpf.c
index cd2f741..7f5b6af 100644
--- a/sched/scx_sjf.bpf.c
+++ b/sched/sjf/scx_sjf.bpf.c
@@ -22,7 +22,7 @@
  */
 #include <string.h>
 #include "../scx_common.bpf.h"
-#include "../scx_sjf_common.h"
+#include "scx_sjf_common.h"
 
 char _license[] SEC("license") = "GPL";
 
diff --git a/sched/scx_sjf.c b/sched/sjf/scx_sjf.c
similarity index 99%
rename from sched/scx_sjf.c
rename to sched/sjf/scx_sjf.c
index 1d34835..74b18b0 100644
--- a/sched/scx_sjf.c
+++ b/sched/sjf/scx_sjf.c
@@ -29,11 +29,11 @@
 #include <sys/syscall.h>
 #include <map>
 
-#include "user_exit_info.h"
+#include "../user_exit_info.h"
 #include "scx_sjf_common.h"
 #include "scx_sjf.skel.h"
 
-#include "lib/hash.h"
+#include "../../lib/hash.h"
 
 const char help_fmt[] =
 "A minimal userland sched_ext scheduler.\n"
diff --git a/sched/scx_sjf_common.h b/sched/sjf/scx_sjf_common.h
similarity index 91%
rename from sched/scx_sjf_common.h
rename to sched/sjf/scx_sjf_common.h
index 6c7fa3d..e01c474 100644
--- a/sched/scx_sjf_common.h
+++ b/sched/sjf/scx_sjf_common.h
@@ -6,8 +6,8 @@
 
 #define USERLAND_MAX_TASKS 60000
 
-#include "lib/cos_client.h"
-#include "lib/cos.h"
+#include "../../lib/cos_client.h"
+#include "../../lib/cos.h"
 
 /*
  * An instance of a task that has been enqueued by the kernel for consumption
diff --git a/user_exit_info.h b/sched/user_exit_info.h
similarity index 100%
rename from user_exit_info.h
rename to sched/user_exit_info.h
-- 
GitLab