- 
                Notifications
    You must be signed in to change notification settings 
- Fork 304
NUMA bindings support for Shm Segments #161
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
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.
Thank you for making this PR. It looks good overall. Mostly just coding style nits.
79bbf1a    to
    21b8cbb      
    Compare
  
            
          
                cachelib/shm/PosixShmSegment.cpp
              
                Outdated
          
        
      | } | ||
|  | ||
| static void forcePageAllocation(void* addr, size_t size, size_t pageSize) { | ||
| for(volatile char* curAddr = (char*)addr; curAddr < (char*)addr+size; curAddr += pageSize) { | 
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.
please use reinterpret_cast instead of c-style casting.
21b8cbb    to
    682cc63      
    Compare
  
    682cc63    to
    9a6bbb1      
    Compare
  
            
          
                cachelib/shm/SysVShmSegment.cpp
              
                Outdated
          
        
      | return; | ||
| } | ||
|  | ||
| switch (errno) { | 
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.
Do we need a wrapper for handling different error case here just to compile the error message? What would the strerror() have to say here?
Also, it seems that we don't use the any other flag except MPOL_BIND.
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.
strerror() is context independent and too abstract.
Regarding flag variable. Today it is 0 (MPOL_BIND is a mode parameter) when we call mbindImpl(), but it is passed as a parameter to the mbindImpl() function. What if in the future we will set flag with some values?
If we assume that flag is always 0, like in current implementation, the switch block could be simplified to the following:
switch (errno) {
  case EFAULT:
    util::throwSystemError(errno);
    break;
  case EINVAL:
    util::throwSystemError(errno, "Invalid parameters when bind segment to NUMA node(s)");
    break;
  case ENOMEM:
    util::throwSystemError(errno, "Could not bind memory. Insufficient kernel memory was available");
    break;
  default:
    XDCHECK(false);
    util::throwSystemError(errno, "Invalid errno");
  }
Should we simply the implementation for now?
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.
This is just an error path, which is unlikely or unexpected to be hit. Would just printing errno along with strerror() just work for debugging?
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.
Ok, I agree. I have replaced this switch block with strerror()
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
        
          
                cachelib/shm/PosixShmSegment.cpp
              
                Outdated
          
        
      | if(opts_.memBindNumaNodes.empty()) return; | ||
|  | ||
| struct bitmask *oldNodeMask = numa_allocate_nodemask(); | ||
| auto guard = folly::makeGuard([&] { numa_bitmask_free(oldNodeMask); }); | 
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've already added NumaBitMask wrapping the struct bitmask. Why not use it instead of having this destructor? Also, I think you can override the cast operator to struct bitmask and pass the NumaBitMask instead of struct bitmask
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
9a6bbb1    to
    edd034d      
    Compare
  
    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.
Only minor issues.
        
          
                cachelib/shm/SysVShmSegment.cpp
              
                Outdated
          
        
      | return; | ||
| } | ||
|  | ||
| switch (errno) { | 
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.
This is just an error path, which is unlikely or unexpected to be hit. Would just printing errno along with strerror() just work for debugging?
| nit. I think it will be fixed automatically when we pull those, but could you remove the trailing whitespaces and tabs?  | 
edd034d    to
    24996c4      
    Compare
  
    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.
Only minor issues
24996c4    to
    1fbc002      
    Compare
  
    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.
LGTM. Could you resolve Hao's comments?
1fbc002    to
    bda5e07      
    Compare
  
    | @jaesoo-fb has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. | 
    
      
        1 similar comment
      
    
  
    | @jaesoo-fb has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. | 
| @jaesoo-fb has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. | 
    
      
        2 similar comments
      
    
  
    | @jaesoo-fb has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. | 
| @jaesoo-fb has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. | 
| @vinser52 Hi. There are some merge conflicts encountered while importing this ( | 
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.
While you are doing the rebase, could you add space after for and if?
bda5e07    to
    3b3a733      
    Compare
  
    | @vinser52 has updated the pull request. You must reimport the pull request before landing. | 
| 
 Done | 
| @jaesoo-fb has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. | 
3b3a733    to
    e041015      
    Compare
  
    | @vinser52 has updated the pull request. You must reimport the pull request before landing. | 
| Hi @jaesoo-fb, I just fixed one minor issue after the merge. Please re-import this PR again. Sorry for the inconvenience. | 
| @jaesoo-fb has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. | 
| Somehow, I cannot clearly see what has been changed, and also I cannot checkout the intermediate version  Can you confirm? Also, can you remove this white space?  | 
e041015    to
    b5422cf      
    Compare
  
    | @vinser52 has updated the pull request. You must reimport the pull request before landing. | 
| @jaesoo-fb has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. | 
| 
 Yeah, I confirm. After rebase  Trailing whitespace in  | 
| 
 No, I don't think squashing the change is the problem; I expected the git repository should have the old commit accessible until being GCed. Anyway, no worries for this. | 
| @jaesoo-fb merged this pull request in 26e02bf. | 
Summary: Fix OSS builds by adding numa deps to build files. Currently some fail on missing `numa.h`. Context: #161 added the dependencies to the centOS, debian, and ubuntu18 build files. The PR was opened in Sep 2022 but only landed in Dec 2022, and so probably missed out on the fedora, rocky and arch build files which were added in-between those dates. Having had those build actions run on PRs would have caught this (currently, they are only scheduled.) Pull Request resolved: #197 Test Plan: Github Actions builds (ideally, #198 would be landed first.) I've checked that those packages exist for the respective repositories but didn't run them myself. Reviewed By: jaesoo-fb Differential Revision: D43587970 Pulled By: jiayuebao fbshipit-source-id: 8c59e48528042350e576a45ffc3bf2520699f5a9
This set of changes allows binding particular memory segments to the specified NUMA node(s).