From 6f62fe598e885c190fea0b61a72d4db9dc4a15ce Mon Sep 17 00:00:00 2001 From: jimin-kiim <0305jimin@naver.com> Date: Wed, 22 Nov 2023 02:49:21 +0900 Subject: [PATCH 01/11] Feat: printing CPU id in pxt4_file_write_iter --- linux-5.4.214/arch/arm/include/asm/current.h | 5 +++++ pxt4/.rand-write.fio.swp | Bin 0 -> 12288 bytes pxt4/Makefile | 4 ++-- pxt4/calclock.c | 19 +++++++++++++++++++ pxt4/calclock.h | 11 +++++++++++ pxt4/file.c | 16 +++++++++++++++- pxt4/local-fio-test-0-verify.state | Bin 0 -> 192 bytes pxt4/local-fio-test-1-verify.state | Bin 0 -> 192 bytes pxt4/local-fio-test-2-verify.state | Bin 0 -> 192 bytes pxt4/local-fio-test-3-verify.state | Bin 0 -> 192 bytes pxt4/local-fio-test-4-verify.state | Bin 0 -> 192 bytes pxt4/local-fio-test-5-verify.state | Bin 0 -> 192 bytes pxt4/rand-write.fio | 15 +++++++++++++++ pxt4/super.c | 4 +++- 14 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 linux-5.4.214/arch/arm/include/asm/current.h create mode 100644 pxt4/.rand-write.fio.swp create mode 100644 pxt4/calclock.c create mode 100644 pxt4/calclock.h create mode 100644 pxt4/local-fio-test-0-verify.state create mode 100644 pxt4/local-fio-test-1-verify.state create mode 100644 pxt4/local-fio-test-2-verify.state create mode 100644 pxt4/local-fio-test-3-verify.state create mode 100644 pxt4/local-fio-test-4-verify.state create mode 100644 pxt4/local-fio-test-5-verify.state create mode 100644 pxt4/rand-write.fio diff --git a/linux-5.4.214/arch/arm/include/asm/current.h b/linux-5.4.214/arch/arm/include/asm/current.h new file mode 100644 index 000000000..dbba03b8c --- /dev/null +++ b/linux-5.4.214/arch/arm/include/asm/current.h @@ -0,0 +1,5 @@ +static __always_inline struct task_struct *get_current(void) +{ +return this_cpu_read_stable(current_task); +} +#define current get_current() diff --git a/pxt4/.rand-write.fio.swp b/pxt4/.rand-write.fio.swp new file mode 100644 index 0000000000000000000000000000000000000000..899bbdfa4146ae4aab0ce3575b2fdf3f2a16742f GIT binary patch literal 12288 zcmeI&u};E37zgkVcNKMWI&{#57Lcfk>1>Q)6Bk0X*rPepUYqM7;Gho1)z|PXoZWl^ zXCK3_q();*FkvG3U-;*^()+mnwo9*9J3ncOL#IyM%0!iiGg+ohdRZeHs95Rz`i%D9 z`);Q1;hsw1PUbowfp@i+Jx0uY!>V43zB^;%wHd#fTg*4uMc!(<3R z00Izz00bZa0SG`~u>@>dqB~ylQnBpSqA&gGiy=A)KmY;|fB*y_009U<00Izz00b6L zzz>MtR)}`#Chc0b4Hw)<8v-KZBC2haq>Dl95e_(00Izz z00bZa0SG_<0uX?}A_^RdYE?)bh(Xd5eHBR_Q)rT5dSPUm7^`$hnYxi)pn7wLc zX1he!(y0E#i>38R4`ZI5dHWP7Bd@GiBOWzR$&9?|DR{~&Yd@A=Ug7(6yeK9lX5u-H l%b!?V*UvH)>R4)fAn4CooiIvze$*8-U4LeMV}Cw@pig}oYMTH6 literal 0 HcmV?d00001 diff --git a/pxt4/Makefile b/pxt4/Makefile index ab9321f9d..dd3477d03 100644 --- a/pxt4/Makefile +++ b/pxt4/Makefile @@ -9,8 +9,8 @@ pxt4-y := balloc.o bitmap.o block_validity.o dir.o pxt4_jbd3.o extents.o \ extents_status.o file.o fsmap.o fsync.o hash.o ialloc.o \ indirect.o inline.o inode.o ioctl.o mballoc.o migrate.o \ mmp.o move_extent.o namei.o page-io.o readpage.o resize.o \ - super.o symlink.o sysfs.o xattr.o xattr_trusted.o xattr_user.o - + super.o symlink.o sysfs.o xattr.o xattr_trusted.o xattr_user.o \ + calclock.o pxt4-m += acl.o pxt4-m += xattr_security.o pxt4-m += verity.o diff --git a/pxt4/calclock.c b/pxt4/calclock.c new file mode 100644 index 000000000..11bd8a330 --- /dev/null +++ b/pxt4/calclock.c @@ -0,0 +1,19 @@ +#include "calclock.h" +unsigned long long calclock(struct timespec *myclock, +unsigned long long *total_time, unsigned long long *total_count) + +{ + unsigned long long timedelay = 0, temp = 0, temp_n = 0; + if (myclock[1].tv_nsec >= myclock[0].tv_nsec) { + temp = myclock[1].tv_sec - myclock[0].tv_sec; + temp_n = myclock[1].tv_nsec - myclock[0].tv_nsec; + timedelay = BILLION * temp + temp_n; + } else { + temp = myclock[1].tv_sec - myclock[0].tv_sec - 1; + temp_n = BILLION + myclock[1].tv_nsec - myclock[0].tv_nsec; + timedelay = BILLION * temp + temp_n; + } + __sync_fetch_and_add(total_time, timedelay); + __sync_fetch_and_add(total_count, 1); + return timedelay; +} diff --git a/pxt4/calclock.h b/pxt4/calclock.h new file mode 100644 index 000000000..a62936bfe --- /dev/null +++ b/pxt4/calclock.h @@ -0,0 +1,11 @@ +#ifndef __CALCLOCK_H +#define __CALCLOCK_H + +#include + +#define BILLION 1000000000UL + +unsigned long long calclock(struct timespec *myclock, + unsigned long long *total_time, unsigned long long *total_clock); + +#endif diff --git a/pxt4/file.c b/pxt4/file.c index 9b74fbb46..1f1babe29 100644 --- a/pxt4/file.c +++ b/pxt4/file.c @@ -33,6 +33,7 @@ #include "pxt4_jbd3.h" #include "xattr.h" #include "acl.h" +#include "calclock.h" #ifdef CONFIG_FS_DAX static ssize_t pxt4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) @@ -217,7 +218,7 @@ pxt4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) #endif static ssize_t -pxt4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) +pxt4_file_write_iter_internal(struct kiocb *iocb, struct iov_iter *from) { struct inode *inode = file_inode(iocb->ki_filp); int o_direct = iocb->ki_flags & IOCB_DIRECT; @@ -286,6 +287,19 @@ pxt4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) inode_unlock(inode); return ret; } +unsigned long long file_write_iter_time, file_write_iter_count; + +static ssize_t pxt4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) { + ssize_t ret; + struct timespec myclock[2]; + + getrawmonotonic(&myclock[0]); + ret = pxt4_file_write_iter_internal(iocb, from); + getrawmonotonic(&myclock[1]); + calclock(myclock, &file_write_iter_time, &file_write_iter_count); + printk("cpu[%d] called pxt4_file_write_iter()",current->cpu); + return ret; +} #ifdef CONFIG_FS_DAX static vm_fault_t pxt4_dax_huge_fault(struct vm_fault *vmf, diff --git a/pxt4/local-fio-test-0-verify.state b/pxt4/local-fio-test-0-verify.state new file mode 100644 index 0000000000000000000000000000000000000000..f6f9c5abd0fa82c60a66e6b805d50b741ca61dcc GIT binary patch literal 192 wcmZQ(fPfWHIw)p(2Z+fC<%4Jln*%CB8I_iquUnE@Ttb;CK;0ky*MrOe0KGs69RL6T literal 0 HcmV?d00001 diff --git a/pxt4/local-fio-test-1-verify.state b/pxt4/local-fio-test-1-verify.state new file mode 100644 index 0000000000000000000000000000000000000000..b38936cb8504211b00edec47473097284a46d698 GIT binary patch literal 192 zcmZQ(fPfWHTIvq_HxQE%$_LR9HV0S)CJvP*nM%vd*DXmcE+JVXx`q$`>p?;Q*G33L literal 0 HcmV?d00001 diff --git a/pxt4/local-fio-test-2-verify.state b/pxt4/local-fio-test-2-verify.state new file mode 100644 index 0000000000000000000000000000000000000000..2c7f7f989adfcba4adc965aa66bb185178726d02 GIT binary patch literal 192 ycmZQ(fPfWH`cTZaQV^37$_LR9HV0UQ2`Wx5m6n;WTasE_Lau(ez7PNFL2LjMstB6^ literal 0 HcmV?d00001 diff --git a/pxt4/local-fio-test-3-verify.state b/pxt4/local-fio-test-3-verify.state new file mode 100644 index 0000000000000000000000000000000000000000..4e5ba4a99b2dec5a397624a963d1a34419f59adf GIT binary patch literal 192 ycmZQ(fPfWHy6cV_H;Bmy<%4Jln*%Ju3>7DrO3TdGElDjdAy+?K--rM8AT|J-sR!x+ literal 0 HcmV?d00001 diff --git a/pxt4/local-fio-test-4-verify.state b/pxt4/local-fio-test-4-verify.state new file mode 100644 index 0000000000000000000000000000000000000000..14d6b4889e7b41c2a0f692c8970779b942ab50c3 GIT binary patch literal 192 ycmZQ(fPfWHx>?(@9K>XV@fo+fr^t$rDf*pmZTP!kgFfA@5BFk5E}q=PzSOA literal 0 HcmV?d00001 diff --git a/pxt4/local-fio-test-5-verify.state b/pxt4/local-fio-test-5-verify.state new file mode 100644 index 0000000000000000000000000000000000000000..b3c181bf474445992f9686d137559f9ad1158718 GIT binary patch literal 192 ycmZQ(fPfWH`t<6RoFFD6ln Date: Wed, 22 Nov 2023 04:54:09 +0900 Subject: [PATCH 02/11] Feat: adding ds_monitoring.h .c --- pxt4/.ds_monitoring.h.swp | Bin 0 -> 12288 bytes pxt4/ds_monitoring.c | 66 ++++++++++++++++++++++++++++++++++++++ pxt4/ds_monitoring.h | 53 ++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 pxt4/.ds_monitoring.h.swp create mode 100644 pxt4/ds_monitoring.c create mode 100644 pxt4/ds_monitoring.h diff --git a/pxt4/.ds_monitoring.h.swp b/pxt4/.ds_monitoring.h.swp new file mode 100644 index 0000000000000000000000000000000000000000..411708db9cb9c2edda298acf6fdf359d4c286d9b GIT binary patch literal 12288 zcmeI2-D(p-6vwAtsH?3ldLyDR8Z1c&Y3nxx!D4F(*jCdj3d*w0PSdr?CTu2>QtQVv z_yN7}1-uZ&zJnJEK7is2c;geO|C!lMvu#2Hy(*rCA4zs*&N=g&nT66_7`>aH=2x;~ z4A&52@2rR7I6J{ko?`5gSMhvxe}}8reouABk+SDEnj^KQyfEU{?Ml`6WHs>oQg&&F zJk(4E$iQw446yU(#zs|y#F^9l*wH(?2}Wbd02v?yWPl8i0Wv@a$N(AGV+Lfck3B=p z`@*^}hM#>~KEt2%K?cYG86X2>fDDiUGC&5%02v?yWPl9pK?9D<*r3JOU!eZ~AN~FR zbC9w3;5l%?WiSA~A7N|*tb;e;HFyPHf+t`BTmwU30Q7_31C0Fu-@pd=2tI%km;(F2 zMn7YpKna`$2f?qy7z4h7FW@a$2QR=fmGPjupfLrgm)LfCC~>LQ1knv=13PA zAOmE843GgbKnDJI1COho%Uw|xQrNNAF_U!}G>VePZt}ESN#&RxRKrV~vWGEguE*4+ zBfTQmLp{GPf?md|d>P*G>t4whE-zR868C&pG&3ep8iltCT0~0^^_ZBtj%YZuL{o~u z=N;$lI~9>*30EM2;1iSAZ;lrx?TI;idUhs1KU>JpO!1`Zl;RH6Gnawc$(EIBM>yDF}0CxakCev!d>=f>z4*RCXRolTpVozRqkRwUsr? zqJkoY`LXEhOjfoeq^$}?OZ3%_HEOqEtLHYO#&GS5RlhDfI>K~Cfb~TOt`Z~?VPS|B zo5|#j{LB`2_Ux@WtuLdCiqggkjOJnH*>#nWEw(Jil_@AP7Ap^X*_zmGO*yP>806k~ zp)h`5&nA&D8B@9TmF$qK=eesuYz-C1&x1Y`dQ+jPxa0&pt>(C`-?CWAu}x;?b{qZ!j#4a*GEom_s+F&l%WgZT`sIxmlix2B*!)^BDzx&UAuL& zm+3mfIN4O&y=OeOc~Z5)>PJp8y?H=W$yQr?3Z6_yn?IF|J*Rkh#nYJXI@y-~9ap>U HsIIbqlJO;B literal 0 HcmV?d00001 diff --git a/pxt4/ds_monitoring.c b/pxt4/ds_monitoring.c new file mode 100644 index 000000000..a021e23c8 --- /dev/null +++ b/pxt4/ds_monitoring.c @@ -0,0 +1,66 @@ +#include "ds_monitoring.h" + +void find_ds_monitoring(struct ds_monitoring *dm, void *elem) +{ + struct ds_monitoring_elem *cur; + unsigned long xa_index; + if (dm->dm_ops->get_index) { + xa_index = dm->dm_ops->get_index(elem); + // search ds_monitoring_elem at index of xa_index from xarray root + cur = (struct ds_monitoring_elem *) xa_load(dm->elements, xa_index); + if (cur) { + __sync_fetch_and_add(&cur->count, 1); + } else { + insert_ds_monitoring(dm, xa_index, elem); + } + __sync_fetch_and_add(&dm->total_counts, 1); + } +} + +insert_ds_monitoring(struct ds_monitoring *dm, unsigned long index, void *elem) +{ + char *name; + struct ds_monitoring_elem *new = kmalloc(sizeof(struct ds_monitoring_elem), + GFP_KERNEL); + new->key = index; + new->count = 1; + if (dm->dm_ops->get_name) { + name = dm->dm_ops->get_name(elem); + new->name = kmalloc(strlen(name)+1, GFP_KERNEL); + strcpy(new->name, name); + } else { + new->name = NULL; + } + xa_store(dm->elements, new->key, (void*) new, GFP_KERNEL); +} + +void print_ds_monitoring(struct ds_monitoring* dm) +{ + unsigned long cur_idx; + void *cur; + char *cur_name; + unsigned long long cur_count; + int percentage; + if (!dm->total_counts) + return; + xa_for_each(dm->elements, cur_idx, cur) { + cur_name = ((struct ds_monitoring_elem *)cur)->name; + cur_count = ((struct ds_monitoring_elem *)cur)->count; + percentage = cur_count * 100 / dm->total_counts; + dm->dm_ops->print_elem(cur_idx, cur_name, cur_count, percentage); + } +} + +void delete_ds_monitoring(struct ds_monitoring *dm) +{ + unsigned long cur_idx; + void *cur; + char *cur_name; + xa_for_each(dm->elements, cur_idx, cur) { + cur_name = ((struct ds_monitoring_elem *)cur)->name; + kfree(cur_name); + kfree(cur); + } + xa_destroy(dm->elements); +} + diff --git a/pxt4/ds_monitoring.h b/pxt4/ds_monitoring.h new file mode 100644 index 000000000..b91ebe9a4 --- /dev/null +++ b/pxt4/ds_monitoring.h @@ -0,0 +1,53 @@ +struct ds_monitoring_operations { + unsigned long (*get_index)(void *elem); + const char * (*get_name)(void *elem); + void (*print_elem)( + unsigned long index, + const char *name, + unsigned long long count, + int percentage + ); +}; + + + +struct ds_monitoring { + struct xarray *elements; + unsigned long long total_counts; + const struct ds_monitoring_operations *dm_ops; +}; + +struct ds_monitoring_elem { + unsigned long key; + char *name; + unsigned long long count; +}; + +#define DEFINE_DS_MONITORING(name, get_idx_fn, get_name_fn, print_fn); \ + DEFINE_XARRAY(name##xarray); \ + DEFINE_DS_MONITORING_OPS(name, get_idx_fn, get_name_fn, print_fn);\ + struct ds_monitoring name = DS_MONITORING_INIT(name##xarray, name##_dm_ops); + +#define DEFINE_DS_MONITORING_OPS(name, get_idx_fn, get_name_fn, print_fn) \ + static const struct ds_monitoring_operations name##_dm_ops = { \ + .get_index = get_idx_fn, \ + .get_name = get_name_fn, \ + .print_elem = print_fn, \ + } + +#define DS_MONITORING_INIT(xarray, _dm_ops) \ +{ \ + .elements = &xarray, \ + .total_counts = 0, \ + .dm_ops = &_dm_ops, \ +} + +#define DECLARE_DS_MONITORING (name) \ + extern struct ds_monitoring name; + +void find_ds_monitoring(struct ds_monitoring *dm, void *elem); +static void insert_ds_monitoring(struct ds_monitoring *dm, unsigned long index, void *elem); +void print_ds_monitoring(struct ds_monitoring* dm); +void delete_ds_monitoring(struct ds_monitoring *dm); + + From 3f917701ceaf0a3bf2b029516cc5f5ecd525da9b Mon Sep 17 00:00:00 2001 From: jimin-kiim <0305jimin@naver.com> Date: Wed, 22 Nov 2023 04:55:37 +0900 Subject: [PATCH 03/11] Fix: removing static function in header file --- pxt4/ds_monitoring.h | 1 - 1 file changed, 1 deletion(-) diff --git a/pxt4/ds_monitoring.h b/pxt4/ds_monitoring.h index b91ebe9a4..8e2ec7fc0 100644 --- a/pxt4/ds_monitoring.h +++ b/pxt4/ds_monitoring.h @@ -46,7 +46,6 @@ struct ds_monitoring_elem { extern struct ds_monitoring name; void find_ds_monitoring(struct ds_monitoring *dm, void *elem); -static void insert_ds_monitoring(struct ds_monitoring *dm, unsigned long index, void *elem); void print_ds_monitoring(struct ds_monitoring* dm); void delete_ds_monitoring(struct ds_monitoring *dm); From d035a81243aeddeef62588f697fa8fd6ff19d72e Mon Sep 17 00:00:00 2001 From: jimin-kiim <0305jimin@naver.com> Date: Wed, 22 Nov 2023 05:09:06 +0900 Subject: [PATCH 04/11] Fix: deleting blank between macro name and left parenthesis --- pxt4/ds_monitoring.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pxt4/ds_monitoring.h b/pxt4/ds_monitoring.h index 8e2ec7fc0..e5a54b59f 100644 --- a/pxt4/ds_monitoring.h +++ b/pxt4/ds_monitoring.h @@ -23,7 +23,7 @@ struct ds_monitoring_elem { unsigned long long count; }; -#define DEFINE_DS_MONITORING(name, get_idx_fn, get_name_fn, print_fn); \ +#define DEFINE_DS_MONITORING(name, get_idx_fn, get_name_fn, print_fn) \ DEFINE_XARRAY(name##xarray); \ DEFINE_DS_MONITORING_OPS(name, get_idx_fn, get_name_fn, print_fn);\ struct ds_monitoring name = DS_MONITORING_INIT(name##xarray, name##_dm_ops); @@ -42,7 +42,7 @@ struct ds_monitoring_elem { .dm_ops = &_dm_ops, \ } -#define DECLARE_DS_MONITORING (name) \ +#define DECLARE_DS_MONITORING(name) \ extern struct ds_monitoring name; void find_ds_monitoring(struct ds_monitoring *dm, void *elem); From c64d7bd37d785723e6299bf9ff35e2b8da8c1a8d Mon Sep 17 00:00:00 2001 From: jimin-kiim <0305jimin@naver.com> Date: Wed, 22 Nov 2023 05:22:59 +0900 Subject: [PATCH 05/11] Fix: including libraries --- pxt4/ds_monitoring.c | 3 ++- pxt4/ds_monitoring.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pxt4/ds_monitoring.c b/pxt4/ds_monitoring.c index a021e23c8..74149dfc8 100644 --- a/pxt4/ds_monitoring.c +++ b/pxt4/ds_monitoring.c @@ -1,4 +1,5 @@ #include "ds_monitoring.h" +#include void find_ds_monitoring(struct ds_monitoring *dm, void *elem) { @@ -16,7 +17,7 @@ void find_ds_monitoring(struct ds_monitoring *dm, void *elem) __sync_fetch_and_add(&dm->total_counts, 1); } } - +static void insert_ds_monitoring(struct ds_monitoring *dm, unsigned long index, void *elem) { char *name; diff --git a/pxt4/ds_monitoring.h b/pxt4/ds_monitoring.h index e5a54b59f..47259ccf3 100644 --- a/pxt4/ds_monitoring.h +++ b/pxt4/ds_monitoring.h @@ -1,3 +1,7 @@ +#include + + + struct ds_monitoring_operations { unsigned long (*get_index)(void *elem); const char * (*get_name)(void *elem); From 861e59186333f889e0c7275cfd6d9f1b14d87860 Mon Sep 17 00:00:00 2001 From: jimin-kiim <0305jimin@naver.com> Date: Wed, 22 Nov 2023 05:25:13 +0900 Subject: [PATCH 06/11] Fix: static declaration of 'func_name' follows non-static declaration error --- pxt4/ds_monitoring.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/pxt4/ds_monitoring.c b/pxt4/ds_monitoring.c index 74149dfc8..ff4370b27 100644 --- a/pxt4/ds_monitoring.c +++ b/pxt4/ds_monitoring.c @@ -1,22 +1,6 @@ #include "ds_monitoring.h" #include -void find_ds_monitoring(struct ds_monitoring *dm, void *elem) -{ - struct ds_monitoring_elem *cur; - unsigned long xa_index; - if (dm->dm_ops->get_index) { - xa_index = dm->dm_ops->get_index(elem); - // search ds_monitoring_elem at index of xa_index from xarray root - cur = (struct ds_monitoring_elem *) xa_load(dm->elements, xa_index); - if (cur) { - __sync_fetch_and_add(&cur->count, 1); - } else { - insert_ds_monitoring(dm, xa_index, elem); - } - __sync_fetch_and_add(&dm->total_counts, 1); - } -} static void insert_ds_monitoring(struct ds_monitoring *dm, unsigned long index, void *elem) { @@ -35,6 +19,23 @@ insert_ds_monitoring(struct ds_monitoring *dm, unsigned long index, void *elem) xa_store(dm->elements, new->key, (void*) new, GFP_KERNEL); } +void find_ds_monitoring(struct ds_monitoring *dm, void *elem) +{ + struct ds_monitoring_elem *cur; + unsigned long xa_index; + if (dm->dm_ops->get_index) { + xa_index = dm->dm_ops->get_index(elem); + // search ds_monitoring_elem at index of xa_index from xarray root + cur = (struct ds_monitoring_elem *) xa_load(dm->elements, xa_index); + if (cur) { + __sync_fetch_and_add(&cur->count, 1); + } else { + insert_ds_monitoring(dm, xa_index, elem); + } + __sync_fetch_and_add(&dm->total_counts, 1); + } +} + void print_ds_monitoring(struct ds_monitoring* dm) { unsigned long cur_idx; From 04752d7186c77378a500f59694aa03bed0886e39 Mon Sep 17 00:00:00 2001 From: jimin-kiim <0305jimin@naver.com> Date: Wed, 22 Nov 2023 05:30:56 +0900 Subject: [PATCH 07/11] Feat: adding ds_monitoring.o in Makefile --- pxt4/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pxt4/Makefile b/pxt4/Makefile index dd3477d03..d83d09247 100644 --- a/pxt4/Makefile +++ b/pxt4/Makefile @@ -10,7 +10,7 @@ pxt4-y := balloc.o bitmap.o block_validity.o dir.o pxt4_jbd3.o extents.o \ indirect.o inline.o inode.o ioctl.o mballoc.o migrate.o \ mmp.o move_extent.o namei.o page-io.o readpage.o resize.o \ super.o symlink.o sysfs.o xattr.o xattr_trusted.o xattr_user.o \ - calclock.o + calclock.o ds_monitoring.o pxt4-m += acl.o pxt4-m += xattr_security.o pxt4-m += verity.o From 619770d4df19bf3f077a082996bcd30f08939060 Mon Sep 17 00:00:00 2001 From: jimin-kiim <0305jimin@naver.com> Date: Wed, 22 Nov 2023 05:34:31 +0900 Subject: [PATCH 08/11] Feat: monitoring target function usage --- pxt4/file.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pxt4/file.c b/pxt4/file.c index 1f1babe29..0a3dc1364 100644 --- a/pxt4/file.c +++ b/pxt4/file.c @@ -287,6 +287,25 @@ pxt4_file_write_iter_internal(struct kiocb *iocb, struct iov_iter *from) inode_unlock(inode); return ret; } + +#include "ds_monitoring.h" +static unsigned long get_cpu_id(void *elem) +{ + return current->cpu; +} + +static const char * get_cpu_name(void *elem) +{ + return ""; +} + +static void print_cpu_dm(unsigned long id, const char * name, unsigned long long count, int percentage) +{ + printk("cpu %ld called pxt4_file_write_iter() %lld times (%d%%)\n", id, count, percentage); +} + + +DEFINE_DS_MONITORING(cpu_dm, get_cpu_id, get_cpu_name, print_cpu_dm); unsigned long long file_write_iter_time, file_write_iter_count; static ssize_t pxt4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) { @@ -297,7 +316,8 @@ static ssize_t pxt4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) { ret = pxt4_file_write_iter_internal(iocb, from); getrawmonotonic(&myclock[1]); calclock(myclock, &file_write_iter_time, &file_write_iter_count); - printk("cpu[%d] called pxt4_file_write_iter()",current->cpu); + //printk("cpu[%d] called pxt4_file_write_iter()",current->cpu); + find_ds_monitoring(&cpu_dm, current); return ret; } From 13f6cf9cb11d084a6dfb8bd940e94b3de48550be Mon Sep 17 00:00:00 2001 From: jimin-kiim <0305jimin@naver.com> Date: Wed, 22 Nov 2023 05:35:05 +0900 Subject: [PATCH 09/11] Feat: dumping result and destroying dm --- pxt4/super.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pxt4/super.c b/pxt4/super.c index 9d1d64d33..ed1395924 100644 --- a/pxt4/super.c +++ b/pxt4/super.c @@ -6333,6 +6333,10 @@ static int __init pxt4_init_fs(void) return err; } + +#include "ds_monitoring.h" +DECLARE_DS_MONITORING(cpu_dm); + extern unsigned long long file_write_iter_time, file_write_iter_count; static void __exit pxt4_exit_fs(void) { @@ -6350,6 +6354,8 @@ static void __exit pxt4_exit_fs(void) pxt4_exit_pending(); printk("pxt4_file_write_iter is called %llu times and the time interval is %lluns\n", file_write_iter_count, file_write_iter_time); + print_ds_monitoring(&cpu_dm); + delete_ds_monitoring(&cpu_dm); } MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); From 9a58ee8a2c2074c251b4ddd280f3b1634147d36a Mon Sep 17 00:00:00 2001 From: jimin-kiim <0305jimin@naver.com> Date: Wed, 22 Nov 2023 05:42:41 +0900 Subject: [PATCH 10/11] Chore: cleaning up codes --- linux-5.4.214/arch/arm/include/asm/current.h | 2 +- pxt4/ds_monitoring.h | 22 +++++++------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/linux-5.4.214/arch/arm/include/asm/current.h b/linux-5.4.214/arch/arm/include/asm/current.h index dbba03b8c..79b8a25d9 100644 --- a/linux-5.4.214/arch/arm/include/asm/current.h +++ b/linux-5.4.214/arch/arm/include/asm/current.h @@ -1,5 +1,5 @@ static __always_inline struct task_struct *get_current(void) { -return this_cpu_read_stable(current_task); + return this_cpu_read_stable(current_task); } #define current get_current() diff --git a/pxt4/ds_monitoring.h b/pxt4/ds_monitoring.h index 47259ccf3..0a1163913 100644 --- a/pxt4/ds_monitoring.h +++ b/pxt4/ds_monitoring.h @@ -1,20 +1,16 @@ #include - - struct ds_monitoring_operations { - unsigned long (*get_index)(void *elem); - const char * (*get_name)(void *elem); - void (*print_elem)( - unsigned long index, - const char *name, - unsigned long long count, - int percentage - ); + unsigned long (*get_index)(void *elem); + const char * (*get_name)(void *elem); + void (*print_elem)( + unsigned long index, + const char *name, + unsigned long long count, + int percentage + ); }; - - struct ds_monitoring { struct xarray *elements; unsigned long long total_counts; @@ -52,5 +48,3 @@ struct ds_monitoring_elem { void find_ds_monitoring(struct ds_monitoring *dm, void *elem); void print_ds_monitoring(struct ds_monitoring* dm); void delete_ds_monitoring(struct ds_monitoring *dm); - - From 7a8729cfbb40d44f24316a66ac064fb5641ad575 Mon Sep 17 00:00:00 2001 From: jimin-kiim <0305jimin@naver.com> Date: Wed, 22 Nov 2023 05:52:21 +0900 Subject: [PATCH 11/11] Chore: adding ifndef endif in headerfile --- pxt4/ds_monitoring.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pxt4/ds_monitoring.h b/pxt4/ds_monitoring.h index 0a1163913..258aaeed1 100644 --- a/pxt4/ds_monitoring.h +++ b/pxt4/ds_monitoring.h @@ -1,3 +1,6 @@ +#ifndef __DS_MONITORING_H +#define __DS_MONITORING_H + #include struct ds_monitoring_operations { @@ -48,3 +51,5 @@ struct ds_monitoring_elem { void find_ds_monitoring(struct ds_monitoring *dm, void *elem); void print_ds_monitoring(struct ds_monitoring* dm); void delete_ds_monitoring(struct ds_monitoring *dm); + +#endif