Conversation
2a921b7 to
359fe69
Compare
|
I did run the relevant tests and nothing seem to break: ~/dev/GSOC/lunatik task-phased-v2 [!]
❯ sudo lunatik reload
sudo lunatik status
[sudo] password for suryansh:
lunatik is loaded
luadevice is loaded
lualinux is loaded
luanotifier is loaded
luasocket is loaded
luarcu is loaded
luathread is loaded
luafib is loaded
luadata is loaded
luaprobe is loaded
luasyscall is loaded
luaxdp is loaded
luafifo is loaded
luaxtable is loaded
luanetfilter is loaded
luacompletion is loaded
luacrypto_shash is loaded
luacrypto_skcipher is loaded
luacrypto_aead is loaded
luacrypto_rng is loaded
luacrypto_comp is loaded
luacpu is loaded
luahid is loaded
luasignal is loaded
luabyteorder is loaded
lunatik_run is loaded~/dev/GSOC/lunatik task-phased-v2 [!]
❯ echo 'local task = require("linux.task"); print(task.INTERRUPTIBLE, task.UNINTERRUPTIBLE, task.KILLABLE, task.IDLE); return "task OK"' | sudo lunatik
sudo dmesg | tail -5
Lunatik 4.1 Copyright (C) 2023-2026 Ring Zero Desenvolvimento de Software LTDA.
> task OK
> [ 610.149922] 2
[ 610.149924]
[ 610.149925] 258
[ 610.149927]
[ 610.149928] 1026~/dev/GSOC/lunatik task-phased-v2 [!]
❯ echo 'local linux = require("linux"); local task = require("linux.task"); linux.schedule(100, task.INTERRUPTIBLE); return "schedule OK"' | sudo lunatik
Lunatik 4.1 Copyright (C) 2023-2026 Ring Zero Desenvolvimento de Software LTDA.
> schedule OK
> ⏎~/dev/GSOC/lunatik task-phased-v2 [!]
❯ echo 'local linux = require("linux"); print(linux.stat.IRUGO); return "stat OK"' | sudo lunatik
sudo dmesg | tail -1
Lunatik 4.1 Copyright (C) 2023-2026 Ring Zero Desenvolvimento de Software LTDA.
> stat OK
> [ 710.751080] 292Got 292 as expected. What should I do with |
34d4bb1 to
fcb04eb
Compare
you did break the examples, right? we shouldn't break anything.
you should adjust the examples accordingly. |
There was a problem hiding this comment.
I have moved
if tonumber(value) then return value endto
local n = tonumber(value)
if n then return string.format("0x%08x", n) endTo avoid mixing octal and hex. Or should I keep it octal?
(Git diff seem to glitch a bit there so better you look at the new code instead of looking at the diff)
5d75ba8 to
64c7234
Compare
|
@Suryansh-Dey are you still working on this? please, let me know. |
|
I have exams tomorrow and day after tomorrow, I will get back to it on 28th feb. |
good luck! no worries, just wanted to check if we should keep this PR opened.. thanks! |
804d1c7 to
55e8947
Compare
| local function resolve_value(value, constants, prefix, module_name, seen) | ||
| if tonumber(value) then return value end | ||
| local function resolve_value(value, constants, seen) | ||
| if tonumber(value) then return tonumber(value) end |
There was a problem hiding this comment.
Because write_constants now uses string.format('0x%08x', resolved_value) which requires an actual number, not a string. The original returned the raw string "0x00000001" and wrote it with %s.
We need it for:
- Format it consistently as 0x%08x
- Use the bitwise OR operator result | resolved for composite constants like TASK_KILLABLE
There was a problem hiding this comment.
it seems odd to me to convert it twice.. perhaps you should use tonumber on the caller and if type is number here, return it.. not sure.. but you should clean up your logics.. it seems very convoluted to me..
|
@sneaky-potato can you please review it? It's your baby ;-) |
55e8947 to
244eeb3
Compare
| is_or_expr = false | ||
| break | ||
| end | ||
| local resolved = resolve_value(constants[token] or token, prefix, constants, seen) |
There was a problem hiding this comment.
Currently, if seen is nil at the top level (first call), each component initializes its own independent seen in the calls of resolve_value. For it to work correctly, seen must be defined at the top of this function I think.
There was a problem hiding this comment.
Yes, I have added some safety checks without compromising performance.
6cec57b to
5f7de2f
Compare
5f7de2f to
482f434
Compare
| if tonumber(value) then return tonumber(value) end | ||
| seen = seen or {} | ||
| -- recursion check: avoid cyclic defines | ||
| if seen[value] then return nil end |
There was a problem hiding this comment.
Please don't move this. Keep this block above the main loop only, it will allow the method to return early if the macro has been seen.
482f434 to
972b585
Compare
311bc38 to
4454abb
Compare
remove [%w_]+ regex from resolve_value Updating makefile to provide arch Update Makefile Co-authored-by: Ashwani Kumar Kamal <75236490+sneaky-potato@users.noreply.github.com>
4a1a811 to
57c4715
Compare
57c4715 to
914fc2b
Compare
| local function resolve_value(value, constants, prefix, module_name, seen) | ||
| if tonumber(value) then return value end | ||
| local function resolve_value(value, constants, seen) | ||
| if tonumber(value) then return tonumber(value) end |
There was a problem hiding this comment.
Because write_constants now uses string.format('0x%08x', resolved_value) which requires an actual number, not a string. The original returned the raw string "0x00000001" and wrote it with %s.
We need it for:
- Format it consistently as 0x%08x
- Use the bitwise OR operator result | resolved for composite constants like TASK_KILLABLE
| is_or_expr = false | ||
| break | ||
| end | ||
| local resolved = resolve_value(constants[token] or token, prefix, constants, seen) |
There was a problem hiding this comment.
Yes, I have added some safety checks without compromising performance.
| if tonumber(value) then return tonumber(value) end | ||
| seen = seen or {} | ||
| -- recursion check: avoid cyclic defines | ||
| if seen[value] then return nil end |
| module_name = "eth", | ||
| }, | ||
| { | ||
| header = "uapi/linux/stat.h", |
There was a problem hiding this comment.
Switching to linux/stat.h ensures the CPP sees both the UAPI base constants and the internal compound ones like S_IRUGO = (S_IRUSR|S_IRGRP|S_IROTH), which our resolve_value function then resolves into their final numeric values.
|
All the tests are passing now. If the PR is ready to merge and no changes needed I can squash the commits. Please let me know |
| local BUILD = INCLUDE:gsub("/include$", "") | ||
| local CPP = string.format("%s -E -dM -I%s -I%s/include/generated -I%s/arch/%s/include -I%s/arch/%s/include/generated -include linux/kconfig.h", |
There was a problem hiding this comment.
I feel we should accept BUILD as a command line argument instead of INCLUDE to the script.
INCLUDE would then become BUILD .. "/include"
This way we can construct the other paths as well instead of relying on string manipulation.
If you notice in Makefile we already have a variable ${MODULES_BUILD_PATH}
What do you think?
There was a problem hiding this comment.
as you wish
don't you agree with the suggestions? if so, please make your point..
There was a problem hiding this comment.
No, I do agree. I also think it is cleaner.
eb3f494 to
a62618f
Compare
| if clean:find("|") then | ||
| local result = 0 | ||
| for token in clean:gmatch("[^%s|]+") do | ||
| local resolved = resolve_value(token, prefix, constants, seen) |
There was a problem hiding this comment.
Here we are not setting seen[value] = true right before this resolve_value call. This might cause problems right?
There was a problem hiding this comment.
Actually, this won't cause any problems.
The value at this specific point is the literal OR expression string itself. We only need to track the actual macro names in the seen table to detect cycles. Since each individual token inside the OR expression (like TASK_A and TASK_B) gets passed back into resolve_value recursively, they will hit the seen[value] = true block at the bottom when they are resolved as macro references. If an OR expression contains a macro that forms a cycle, it will still be caught perfectly.
Please correct me If I missed something
| @@ -12,6 +12,8 @@ MODULES_BUILD_PATH ?= ${BTF_INSTALL_PATH} | |||
| MODULES_INSTALL_PATH := ${MODULES_RELEASE_PATH}/kernel | |||
| SCRIPTS_INSTALL_PATH := ${MODULES_PATH}/lua | |||
| INCLUDE_PATH := ${MODULES_BUILD_PATH}/include | |||
There was a problem hiding this comment.
This is not used anywhere now, we can safely remove this
There was a problem hiding this comment.
MODULES_INSTALL_PATH := ${MODULES_RELEASE_PATH}/kernel
SCRIPTS_INSTALL_PATH := ${MODULES_PATH}/lua
They get used later in the makefile below, so we can't remove them.
But yes I should have removed line 14. My bad.
| SCRIPTS_INSTALL_PATH := ${MODULES_PATH}/lua | ||
| INCLUDE_PATH := ${MODULES_BUILD_PATH}/include | ||
| KERNEL_ARCH ?= ${shell uname -m} | ||
| ARCH ?= $(subst x86_64,x86,$(subst aarch64,arm64,$(KERNEL_ARCH))) |
There was a problem hiding this comment.
We should never reinvent the wheel.. BTW, we should care about cross compiling; particularly, this should work with OpenWRT feed as well..
There was a problem hiding this comment.
What should I do then?
There was a problem hiding this comment.
I think @sneaky-potato's idea is way to do it, just make sure it works on OpenWRT feed. It must be tested there as well.
There was a problem hiding this comment.
Could you please test if works on OpenWRT feed. I am not sure of that thing, how it works.
There was a problem hiding this comment.
I can help if you would like to do it, but not do it for you. For merging this PR, we need to make sure we don't break it. For building it you can just use our OpenWRT feed pointing to your commit. You probably will need to adjust the makefile there.
Co-authored-by: Ashwani Kumar Kamal <75236490+sneaky-potato@users.noreply.github.com>
a62618f to
bffdd84
Compare
Closes #435
Here is phase 1 of the PR
Now
make configureauto generates hexadecimal constants for both task and stat modules.Phase 2: Move stat constants
Phase 3: Move OR'ed flags (composites)
Ready for the feedback.