Skip to content
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

CTL: Add a CTL sources to the UMF #913

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

KFilipek
Copy link
Contributor

@KFilipek KFilipek commented Nov 19, 2024

Description

This commit introduces sources and compilation of the CTL.

Checklists

TODO:

  • Move CTL sources
  • Make code compiled and symbols are exposed
  • Run tests

Other:

  • Code compiles without errors locally
  • All tests pass locally
  • CI workflows execute properly
  • CI workflows, not executed per PR (e.g. Nightly), execute properly
  • New tests added, especially if they will fail without my changes
  • Added/extended example(s) to cover this functionality
  • Extended the README/documentation
  • All newly added source files have a license
  • All newly added source files are referenced in CMake files
  • Logger (with debug/info/... messages) is used

@KFilipek KFilipek self-assigned this Nov 19, 2024
@KFilipek KFilipek added the enhancement New feature or request label Nov 19, 2024
src/ctl/alloc.h Outdated Show resolved Hide resolved
src/ctl/os.h Outdated Show resolved Hide resolved
src/ctl/queue.h Outdated Show resolved Hide resolved
src/ctl/ctl.h Outdated Show resolved Hide resolved
src/CMakeLists.txt Outdated Show resolved Hide resolved
src/ctl/ctl.c Outdated Show resolved Hide resolved
src/ctl/ctl.h Outdated
* ctl.h -- internal declaration of statistics and control related structures
*/

#ifndef PMDK_CTL_H
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls update all define's to use naming like: UMF_*_H

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not done, e.g. CTL_DEBUG_H

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look once again, this snippet is outdated

src/ctl/ctl.h Show resolved Hide resolved
src/CMakeLists.txt Outdated Show resolved Hide resolved
src/ctl/ctl.c Outdated Show resolved Hide resolved
src/ctl/ctl.c Outdated
*/
int ctl_load_config_from_string(struct ctl *ctl, void *ctx,
const char *cfg_string) {
// LOG(3, "ctl %p ctx %p cfg_string \"%s\"", ctl, ctx, cfg_string);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOG could be replaced with our LOG_* macros

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporarily deleted

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave this issue open, for LOGs to come back, when ready

src/ctl/ctl.h Show resolved Hide resolved
@KFilipek KFilipek force-pushed the ctl-base branch 8 times, most recently from 5c52d3a to cdd3d46 Compare November 22, 2024 10:30
src/ctl/alloc.c Outdated
return fn_malloc(size);
}

static __thread int realloc_num;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this fault injection? this was part of testing infra.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, thanks

@KFilipek KFilipek force-pushed the ctl-base branch 15 times, most recently from 4f30764 to 0f8383e Compare November 29, 2024 08:32
@KFilipek KFilipek force-pushed the ctl-base branch 2 times, most recently from 0d68c68 to 44ec630 Compare December 3, 2024 10:12
@KFilipek KFilipek force-pushed the ctl-base branch 8 times, most recently from dc1d821 to 76b70bc Compare December 11, 2024 13:19
@KFilipek KFilipek marked this pull request as ready for review December 11, 2024 13:22
@KFilipek KFilipek requested a review from a team as a code owner December 11, 2024 13:22
@KFilipek KFilipek force-pushed the ctl-base branch 4 times, most recently from b6d922a to 6cc7810 Compare December 11, 2024 17:16
src/ctl/ctl.c Outdated Show resolved Hide resolved
src/ctl/ctl.c Outdated Show resolved Hide resolved
src/ctl/ctl_debug.c Outdated Show resolved Hide resolved
src/libumf.def Outdated Show resolved Hide resolved
src/libumf.def Outdated Show resolved Hide resolved
test/CMakeLists.txt Outdated Show resolved Hide resolved
test/ctl/test.cpp Outdated Show resolved Hide resolved
test/ctl/test.cpp Outdated Show resolved Hide resolved
int value = 0;
ctl_query(ctl_handler, NULL, CTL_QUERY_PROGRAMMATIC,
"debug.heap.alloc_pattern", CTL_QUERY_READ, &value);
ASSERT_EQ(value, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we definitely need more complex tests

@bratpiorka
Copy link
Contributor

@KFilipek please consider moving this PR to draft and re-request review when ready

Copy link
Contributor

@lukaszstolarczuk lukaszstolarczuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now all changes are in a single commit, at best the original code should be in the first commit and all our changes in a sep. one - this would be easier to distingush our changes, e.g. in case of any issues found

@@ -232,9 +232,8 @@ function(add_umf_target_compile_options name)
PRIVATE -fPIC
-Wall
-Wextra
-Wpedantic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I you want to add this change in this PR, it should be in a sep. commit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/ctl/ctl.h Outdated
* ctl.h -- internal declaration of statistics and control related structures
*/

#ifndef PMDK_CTL_H
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not done, e.g. CTL_DEBUG_H

@@ -0,0 +1,590 @@
// SPDX-License-Identifier: BSD-3-Clause
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's usually first copyright, then a license txt, then SPDX tag, e.g.

/*
 *
 * Copyright (C) 2023-2024 Intel Corporation
 *
 * Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 *
 */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

? 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? 😉

I cannot reply in thread related with that you see
#913 (comment)

@KFilipek KFilipek marked this pull request as draft December 12, 2024 10:03
@KFilipek KFilipek force-pushed the ctl-base branch 4 times, most recently from df3c47f to ecf3785 Compare December 12, 2024 16:24
This commit introduces sources and compilation of the CTL.
The CTL sources are copied from: https://github.com/pmem/pmdk/tree/master/src/common

Signed-off-by: Krzysztof Filipek <[email protected]>
@bratpiorka bratpiorka marked this pull request as ready for review December 13, 2024 10:36
-Wformat-security
-Wcast-qual
-Wno-cast-qual
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you disable this flag?

};

struct ctl_argument {
size_t dest_size; /* sizeof the entire argument */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: size of

* This function opens up the config file, allocates a buffer of size equal to
* the size of the file, reads its content and sanitizes it for ctl_load_config.
*/
#ifdef WINDOWS_API_NEEDED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unknown define. The code looks like it should work on linux.

if (endptr == str || errno != 0) {
return LLONG_MIN;
}
errno = olderrno;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does errno have to be restored?

* query has been handled.
*/
struct ctl_index_utlist *indexes = NULL;
indexes = Zalloc(sizeof(*indexes));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for NULL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants