-
Notifications
You must be signed in to change notification settings - Fork 574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
log_dump: Add api to get size of the log dump #6394
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove log_dump.c
from the title. You don't make a change only in that file.
bfaf74a
to
2e37810
Compare
os/kernel/log_dump/log_dump.c
Outdated
size_t log_dump_get_size(void) | ||
{ | ||
size_t size = 0; | ||
struct log_dump_chunk_s* head = (struct log_dump_chunk_s *)sq_peek(&log_dump_chunks); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In code readability, head != tail? It looks strange.
How about renaming the variable like log_node?
It does not have the head always.
os/kernel/log_dump/log_dump.c
Outdated
while (head != (struct log_dump_chunk_s *)sq_tail(&log_dump_chunks)) { | ||
head = (struct log_dump_chunk_s *)sq_next((sq_entry_t *)head); | ||
size += CONFIG_LOG_DUMP_CHUNK_SIZE; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Don't you need to do lock / unlock for log dump?
- If tail should be fixed, I think we can get it once. Not every while loop.
- How about calculating current size at every node allocation and free in some static global variable? We already need to get current size to adjust node total size based on free heap size.
os/kernel/log_dump/log_dump.c
Outdated
* Note: It is recommended to use this log_dump_get_size api after | ||
* log_dump_read_wake() is performed, so that it has correct value of last_comp_block_size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
App will use this API and App can't know whether log_dump_read_wake
is performed or not. This recommendation looks redundant. Is there any other way to do it automatically?
os/kernel/log_dump/log_dump.c
Outdated
* Note: It is recommended to use this log_dump_get_size api after | ||
* log_dump_read_wake() is performed, so that it has correct value of last_comp_block_size. | ||
* Else it might add old last_comp_block_size which is already present in log_dump_chunk list */ | ||
size += last_comp_block_size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You return compressed log size + uncompressed log size. When we read saved log dump, don't we compress uncompressed log?? If we don't, then how can we know how many data should be uncompressed and how many data should be used as it is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Earlier, when we were opening the procfs file of log dump, it was compressing the partially filled log buffer. Now the compressing the partially filled log buffer has been shifted to when log dump save is stopped . So that whenever we stop log dump process, we will compress the partially filled log buffer and update the size.
two cases while getting log dump size:
- When log dump save is true and log dump is saving character : In this case , log dump size will return the size of compressed logs till now in the log_dump_chuck and it will not include last_comp_block_size becuase it is not valid.
- when log dump save is false and log dump is not saving : In this case , log dump size will include compressed logs in log_dump_chunk + last_comp_block_size becuase after log dump save is stopped we will compress the last partially filled logs.
@ritesh55555 One question, after getting the size using new API, is there any chance that node size is changed? |
2e37810
to
ee10c01
Compare
It is recommended that log dump size and log dump read should be done after stopping log dump save process. Else app might not get the value wanted . |
8046bc3
to
aa3b9f9
Compare
* is compressed and size should include last_comp_block_size */ | ||
if (is_started_to_save == false) { | ||
return log_dump_chunk_node_cnt * CONFIG_LOG_DUMP_CHUNK_SIZE + compress_curbytes + last_comp_block_size; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The else case means, top_logsave has not been called. So, if we return some size here and there is some timegap before read, then the size will differ. It is better to return error code here. This api must be called only when log dump has been stopped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you added the else case to check stop first. How about adding it at the read function as well? Because it's the same.
2e567e6
to
10cd880
Compare
10cd880
to
4f2fb0a
Compare
@ritesh55555 Pls add the output of the log dump app in the commit description. |
4f2fb0a
to
4622c3c
Compare
- This commit adds an api to get the size of the compressed log dump. It also places the work of compressing the partially filled log buffer when log save is stopped.
4622c3c
to
6e1161e
Compare
- This commit add code in log_dump_main app to verify working of log_dump_get_size() api. It calculates total length of compressed logs by continuously reading throught a fixed buffer and then verify the size with the value returned from log_dump_get_size() api. followings are the logs from log_dump_main app: (Note the compressed output is commented because it gives garbage value , we are only printing to check log dump size comparison with total read value from buffer) TASH>>log_dump TASH>>This Log Should NOT be saved!!! ********************* LOG DUMP START ********************* This Log Should be saved!!! log_dump_size = 2892, and total_read = 2892, Both should be equal ********************* LOG DUMP END ***********************
/* Should we return error from here?? because partially filled uncompressed buffer | ||
* might not be compressed but log_dump save has stopped now, so operation is success */ | ||
} | ||
} else if (strncmp(buffer, LOGDUMP_GET_SIZE, strlen(LOGDUMP_GET_SIZE) + 1) == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 3 strncmp s to check a command. It looks not good.
Because the data is a just character, how about using switch / case?
* is compressed and size should include last_comp_block_size */ | ||
if (is_started_to_save == false) { | ||
return log_dump_chunk_node_cnt * CONFIG_LOG_DUMP_CHUNK_SIZE + compress_curbytes + last_comp_block_size; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you added the else case to check stop first. How about adding it at the read function as well? Because it's the same.
@ritesh55555 I left two comments, but I think it's different topic against this PR so that you can do that with new PR or new commit. |
This commit adds an api to get the size of the compressed log dump.