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

Memory problem #46

Open
HuangHao404 opened this issue Nov 13, 2024 · 3 comments
Open

Memory problem #46

HuangHao404 opened this issue Nov 13, 2024 · 3 comments
Labels
invalid This doesn't seem right

Comments

@HuangHao404
Copy link

Describe the bug
The value of the variable was changed after defining a page_cache_t type
Code:

int num_of_candidates = 64;
Data* query_points = new Data(query_path);
std::cout << "Search...Query number: " <<query_points->GetNumPoints()<<" Num of candidates: "<<num_of_candidates<<std::endl 
Settings settings;
std::vector<Controller *> ctrls(settings.n_ctrls);
const char *const ctrls_paths[] = {"/dev/libnvm0"};
ctrls[0] = new Controller(ctrls_paths[0], settings.nvmNamespace,
                              settings.cudaDevice, settings.queueDepth,
                              settings.numQueues);
uint64_t pc_pages = settings.maxPageCacheSize / settings.pageSize;
page_cache_t h_pc(settings.pageSize, pc_pages, settings.cudaDevice, ctrls[0][0], (uint64_t)64, ctrls);
std::cout << "Search...Query number: " <<query_points->GetNumPoints()<<" Num of candidates: "<<num_of_candidates << std::endl;

Output:

Search...Query number: 10000 Num of candidates: 64
SQs: 129        CQs: 129        n_qps: 1
pageSize 1024, pageNum 8192, cudaDevice 0
n_ranges_bits: 6
n_ranges_mask: 63
pages_dma: 0x7ff0a4e10000       215000a10000
HEREN
Cond1
2000 8 4 800
Finish Making Page Cache
Search...Query number: 2710 Num of candidates: 40

The Query number change from 10000 to 2710, and Num of candidates change from 64 to 40
And there are my parameters of Settings:

Settings::Settings()
{
    cudaDevice = 0;
    cudaDeviceId = 0;
    blockDevicePath = nullptr;
    controllerPath = nullptr;
    controllerId = 0;
    adapter = 0;
    segmentId = 0;
    nvmNamespace = 1;
    doubleBuffered = false;
    numReqs = 1;
    numPages = 1024;
    startBlock = 0;
    stats = false;
    input = nullptr;
    output = nullptr;
    ifileoffset = 0; 
    ofileoffset = 0; 
    numThreads = 64;
    blkSize = 64;
    domain = 0;
    bus = 0;
    devfn = 0;
    n_ctrls = 1;
    queueDepth = 1024;
    numQueues = 1;
    pageSize = 1024;
    numBlks = 2097152;
    random = true;
    accessType = WRITE;
    ratio = 100;
    // maxPageCacheSize = 8589934592;
    maxPageCacheSize = 8388608;
}
@msharmavikram
Copy link
Collaborator

I have no idea what this is about! What are you even cooking here?

Without proper details, I will have to mark this as an invalid issue.

@msharmavikram msharmavikram added the invalid This doesn't seem right label Nov 13, 2024
@HuangHao404
Copy link
Author

 The variable num_of_candidates declared externally changed its value (from 64 to 40) after calling the page_cache_t constructor. There might be some memory management issues in the page_cache_t constructor.
 For example, in lines 833 to 846 of page_cache.h, temp1 is allocated with a size of np * sizeof(uint64_t), but its usage seems to only be for np. Even after I modified the memory allocation issues for temp1, temp2, and temp3, the error still persists. Could there be other memory management issues inside?
Code in page_cache.h from 833 to 846:

uint64_t* temp1 = new uint64_t[np * sizeof(uint64_t)];
uint64_t* temp2 = new uint64_t[np * sizeof(uint64_t)];
uint64_t* temp3 = new uint64_t[prp_list_size];
std::memset(temp1, 0, np * sizeof(uint64_t));
std::memset(temp2, 0, np * sizeof(uint64_t));
std::memset(temp3, 0, prp_list_size);
uint32_t how_many_in_one = ps /  ctrl.ctrl->page_size ;
for (size_t i = 0; i < np; i++) {
      temp1[i] = ((uint64_t) this->pages_dma.get()->ioaddrs[i*how_many_in_one]);
      temp2[i] = ((uint64_t) this->prp_list_dma.get()->ioaddrs[i]);
      for(size_t j = 0; j < (how_many_in_one-1); j++) {
           temp3[i*uints_per_page + j] = ((uint64_t) this->pages_dma.get()->ioaddrs[i*how_many_in_one + j + 1]);
       }
}

I have no idea what this is about! What are you even cooking here?

Without proper details, I will have to mark this as an invalid issue.

@HuangHao404
Copy link
Author

After I commented out line 772 in page_cache.h, the error disappeared

Line 772:

std::cout << "pages_dma: " << std::hex << this->pages_dma.get()->vaddr << "\t" << this->pages_dma.get()->ioaddrs[0] << std::endl;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants