NVSL / linux-nova

NOVA is a log-structured file system designed for byte-addressable non-volatile memories, developed at the University of California, San Diego.
http://nvsl.ucsd.edu/index.php?path=projects/nova
Other
421 stars 118 forks source link

Can you provide a guide or document for Ziggurat? #87

Open nayabin opened 3 years ago

nayabin commented 3 years ago

Hello :) Can you provide a guide or document for Ziggurat? I would like to try it out and check its performance, but I got the following compile error.

./arch/x86/include/asm/mmu_context.h: In function ‘ldt_slot_va’: ./arch/x86/include/asm/mmu_context.h:74:18: error: ‘LDT_BASE_ADDR’ undeclared (first use in this function); did you mean ‘FTRACE_ADDR’? return (void )(LDT_BASE_ADDR + LDT_SLOT_STRIDE slot); ^~~~~ FTRACE_ADDR

nayabin commented 3 years ago

Could you kindly answer my question? If you have any more information you need, please tell me.

mhoseinzadeh commented 3 years ago

Are you compiling it on an x86-64 machine? Either way, change it to the following:

static inline void *ldt_slot_va(int slot)
{
#ifdef CONFIG_X86_64
    return (void *)(LDT_BASE_ADDR + LDT_SLOT_STRIDE * slot);
#else
    BUG();
    return (void *)fix_to_virt(FIX_HOLE);
#endif
}
nayabin commented 3 years ago

Even applying the code snippet you gave me, I get the same error. I'm working on the commit tree below, and I've seen LDT_BASE_ADDR removed from this commit. https://github.com/NVSL/linux-nova/commit/3ce813f0b82e7604dd45cf84ac3c506463592897 Are there any problems with your build? I ran the build with the x86_64 arch, should I run it with a different arch?

thistleknot commented 3 years ago

after installing bc and openssl-devel I finally got it started on compiling for more than 30 seconds and I got the same error LDT_BASE_ADDR

I applied the suggested fix and then did a make clean and reran make

and...

In file included from arch/x86/events/core.c:37:
./arch/x86/include/asm/mmu_context.h: In function ‘ldt_slot_va’:
./arch/x86/include/asm/mmu_context.h:75:18: error: ‘LDT_BASE_ADDR’ undeclared (first use in this function); did you mean ‘FTRACE_ADDR’?
  return (void *)(LDT_BASE_ADDR + LDT_SLOT_STRIDE * slot);
                  ^~~~~~~~~~~~~
                  FTRACE_ADDR
./arch/x86/include/asm/mmu_context.h:75:18: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [scripts/Makefile.build:276: arch/x86/events/core.o] Error 1
make[1]: *** [scripts/Makefile.build:486: arch/x86/events] Error 2
make: *** [Makefile:1051: arch/x86] Error 2
thistleknot commented 3 years ago

so I added to the top of

mmu_context.h

#define LDT_BASE_ADDR           (LDT_PGD_ENTRY << PGDIR_SHIFT)
#define LDT_PGD_ENTRY           -240UL

and got further

arch/x86/kernel/traps.c:569:7: error: too few arguments to function ‘fixup_exception’
   if (fixup_exception(regs, X86_TRAP_GP))
       ^~~~~~~~~~~~~~~
In file included from ./arch/x86/include/asm/sections.h:6,
                 from ./include/linux/interrupt.h:20,
                 from arch/x86/kernel/traps.c:16:
./arch/x86/include/asm/extable.h:32:12: note: declared here
 extern int fixup_exception(struct pt_regs *regs, int trapnr,

which shows the definition as

extern int fixup_exception(struct pt_regs *regs, int trapnr, unsigned long error_code, unsigned long fault_addr);

Looking around, I see two definitions for the file, one with 2 parameter's https://github.com/torvalds/linux/blob/master/include/asm-generic/extable.h

and one with the long list https://elixir.bootlin.com/linux/latest/source/arch/x86/include/asm/extable.h

in the code itself I see the following for extable


[root@pve0 linux-nova]# find . -name extable.*
./arch/alpha/include/asm/extable.h
./arch/arc/mm/extable.c
./arch/arm/mm/extable.c
./arch/arm64/include/asm/extable.h
./arch/arm64/mm/extable.c
./arch/ia64/include/asm/extable.h
./arch/ia64/mm/extable.c
./arch/mips/include/asm/extable.h
./arch/mips/mm/extable.c
./arch/nds32/mm/extable.c
./arch/nios2/mm/extable.c
./arch/powerpc/include/asm/extable.h
./arch/riscv/mm/extable.c
./arch/s390/include/asm/extable.h
./arch/sh/include/asm/extable.h
./arch/sparc/mm/extable.c
./arch/unicore32/mm/extable.c
./arch/x86/include/asm/extable.h
./arch/x86/mm/extable.c
./include/asm-generic/extable.h
./include/linux/extable.h
./kernel/extable.c
./lib/extable.c

It looks like it's including the wrong header?

[root@pve0 linux-nova]# cat $(find . -name extable.*) | grep fixup_exception
#define fixup_exception(map_reg, _fixup, pc)                    \
int fixup_exception(struct pt_regs *regs)
int fixup_exception(struct pt_regs *regs)
extern int fixup_exception(struct pt_regs *regs);
int fixup_exception(struct pt_regs *regs)
extern int fixup_exception(struct pt_regs *regs);
int fixup_exception(struct pt_regs *regs)
int fixup_exception(struct pt_regs *regs)
int fixup_exception(struct pt_regs *regs)
int fixup_exception(struct pt_regs *regs)
int fixup_exception(struct pt_regs *regs)
extern int fixup_exception(struct pt_regs *regs, int trapnr,
extern void early_fixup_exception(struct pt_regs *regs, int trapnr);
int fixup_exception(struct pt_regs *regs, int trapnr, unsigned long error_code,
void __init early_fixup_exception(struct pt_regs *regs, int trapnr)
        if (fixup_exception(regs, trapnr, regs->orig_ax, 0))
extern int fixup_exception(struct pt_regs *regs);
thistleknot commented 3 years ago

I edited the definition

./arch/x86/include/asm/extable.h

extern int fixup_exception(struct pt_regs *regs);

now I got


arch/x86/kernel/cpu/mce/core.c:1322:8: error: too many arguments to function ‘fixup_exception’
   if (!fixup_exception(regs, X86_TRAP_MC, error_code, 0))
        ^~~~~~~~~~~~~~~
In file included from ./arch/x86/include/asm/uaccess.h:13,
                 from ./include/linux/uaccess.h:11,
                 from arch/x86/kernel/cpu/mce/core.c:17:
./arch/x86/include/asm/extable.h:34:12: note: declared here
 extern int fixup_exception(struct pt_regs *regs);
            ^~~~~~~~~~~~~~~

seems like a function needs to have two sets of definitions

thistleknot commented 3 years ago

I may have found a solution

5.1 seems to compile with less errors (had to follow this guide to comment out a few of the lines in .config asking for .pem)

but comparing traps.c between 5.1 and ziggurat. I see there is a different call in 5.1 than ziggarat (using winmerge)

there are few more changes but I think that's the key one. Will try after done building 5.1 kernel

if (fixup_exception(regs, X86_TRAP_GP))

thistleknot commented 3 years ago

I made traps.c look like v 5.1 when it threw conflicts about that fixup_exception

then next error had to add to mmu_context.h

define LDT_END_ADDR (LDT_BASE_ADDR + PMD_SIZE)

then I got

giving up at this point. 5.1 seems to be compiling fine though.

arch/x86/kernel/setup.c: In function ‘reserve_crashkernel’:
./arch/x86/include/asm/sparsemem.h:31:58: error: pasting ")" and "UL" does not give a valid preprocessing token
 # define MAX_PHYSMEM_BITS (pgtable_l5_enabled() ? 52 : 46)
                                                          ^
./include/uapi/linux/const.h:20:20: note: in definition of macro ‘__AC’
 #define __AC(X,Y) (X##Y)
                    ^
./arch/x86/include/asm/pgtable_64_types.h:106:17: note: in expansion of macro ‘_AC’
 #define MAXMEM  _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL)
                 ^~~
./arch/x86/include/asm/pgtable_64_types.h:106:36: note: in expansion of macro ‘MAX_PHYSMEM_BITS’
 #define MAXMEM  _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL)
                                    ^~~~~~~~~~~~~~~~
arch/x86/kernel/setup.c:463:30: note: in expansion of macro ‘MAXMEM’
 # define CRASH_ADDR_HIGH_MAX MAXMEM
                              ^~~~~~
arch/x86/kernel/setup.c:551:18: note: in expansion of macro ‘CRASH_ADDR_HIGH_MAX’
           high ? CRASH_ADDR_HIGH_MAX
                  ^~~~~~~~~~~~~~~~~~~
./arch/x86/include/asm/pgtable_64_types.h:106:54: error: expected ‘)’ before ‘UL’
 #define MAXMEM  _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL)
                                                      ^~
./include/uapi/linux/const.h:20:23: note: in definition of macro ‘__AC’
 #define __AC(X,Y) (X##Y)
                       ^
./arch/x86/include/asm/pgtable_64_types.h:106:17: note: in expansion of macro ‘_AC’
 #define MAXMEM  _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL)
                 ^~~
arch/x86/kernel/setup.c:463:30: note: in expansion of macro ‘MAXMEM’
 # define CRASH_ADDR_HIGH_MAX MAXMEM
                              ^~~~~~
arch/x86/kernel/setup.c:551:18: note: in expansion of macro ‘CRASH_ADDR_HIGH_MAX’
           high ? CRASH_ADDR_HIGH_MAX
                  ^~~~~~~~~~~~~~~~~~~
./include/uapi/linux/const.h:20:19: note: to match this ‘(’
 #define __AC(X,Y) (X##Y)
                   ^
./include/uapi/linux/const.h:21:18: note: in expansion of macro ‘__AC’
 #define _AC(X,Y) __AC(X,Y)
                  ^~~~
./arch/x86/include/asm/pgtable_64_types.h:106:17: note: in expansion of macro ‘_AC’
 #define MAXMEM  _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL)
                 ^~~
arch/x86/kernel/setup.c:463:30: note: in expansion of macro ‘MAXMEM’
 # define CRASH_ADDR_HIGH_MAX MAXMEM
                              ^~~~~~
arch/x86/kernel/setup.c:551:18: note: in expansion of macro ‘CRASH_ADDR_HIGH_MAX’
           high ? CRASH_ADDR_HIGH_MAX
                  ^~~~~~~~~~~~~~~~~~~
make[2]: *** [scripts/Makefile.build:276: arch/x86/kernel/setup.o] Error 1
make[1]: *** [scripts/Makefile.build:486: arch/x86/kernel] Error 2
make: *** [Makefile:1051: arch/x86] Error 2
byhs commented 3 years ago

According to the Ziggurat paper, Ziggurat is implemented in Linux kernel 4.13.

However, it seems that Ziggurat Branch is currently merged in Linux kernel 5.1.

So I ported Ziggurat to Linux kernel 4.13. And it seems to work.

Can I contribute the Ziggurat kernel code that I ported?

thistleknot commented 3 years ago

please do. If you have instructions (or at least the most important pieces). I'm all ears.

byhs commented 3 years ago

Here is my branch.

https://github.com/byhs/linux-nova/tree/Ziggurat-4.13

Ziggurat uses Block Device, so additional options are required when mounting.

ex) mount -t NOVA -o init,bdev=/dev/sdb /dev/pmem0 /mnt/ziggurat