[Deepin-Kernel-SIG] [linux 6.6.y] [Upstream] mempolicy: remove confusing MPOL_MF_LAZY dead code#1869
Conversation
mainline inclusion from mainline-v6.7-rc1 category: performance v3.8 commit b24f53a ("mm: mempolicy: Add MPOL_MF_LAZY") introduced MPOL_MF_LAZY, and included it in the MPOL_MF_VALID flags; but a720094 ("mm: mempolicy: Hide MPOL_NOOP and MPOL_MF_LAZY from userspace for now") immediately removed it from MPOL_MF_VALID flags, pending further review. "This will need to be revisited", but it has not been reinstated. The present state is confusing: there is dead code in mm/mempolicy.c to handle MPOL_MF_LAZY cases which can never occur. Remove that: it can be resurrected later if necessary. But keep the definition of MPOL_MF_LAZY, which must remain in the UAPI, even though it always fails with EINVAL. https://lore.kernel.org/linux-mm/1553041659-46787-1-git-send-email-yang.shi@linux.alibaba.com/ links to a previous request to remove MPOL_MF_LAZY. Link: https://lkml.kernel.org/r/80c9665c-1c3f-17ba-21a3-f6115cebf7d@google.com Signed-off-by: Hugh Dickins <hughd@google.com> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Yang Shi <shy828301@gmail.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Christoph Lameter <cl@linux.com> Cc: David Hildenbrand <david@redhat.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: "Huang, Ying" <ying.huang@intel.com> Cc: Kefeng Wang <wangkefeng.wang@huawei.com> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Kravetz <mike.kravetz@oracle.com> Cc: Nhat Pham <nphamcs@gmail.com> Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Tejun heo <tj@kernel.org> Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com> Cc: Yosry Ahmed <yosryahmed@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (cherry picked from commit 2cafb58) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion from mainline-v6.9-rc1 category: bugfix Commit 2cafb58 ("mempolicy: remove confusing MPOL_MF_LAZY dead code") removes MPOL_MF_LAZY handling in queue_pages_test_walk(), and with that, there is no effective use of the local variable endvma in that function remaining. Remove the local variable endvma and its dead code. No functional change. This issue was identified with clang-analyzer's dead stores analysis. Link: https://lkml.kernel.org/r/20240122092504.18377-1-lukas.bulwahn@gmail.com Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com> Cc: Hugh Dickins <hughd@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (cherry picked from commit 3efbe13) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRemoves dead MPOL_MF_LAZY handling and an unused NUMA balancing helper stub from the mempolicy implementation, while clarifying that the MPOL_MF_LAZY flag is unsupported in the UAPI header. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- If MPOL_MF_LAZY is now considered unsupported, consider rejecting it explicitly in do_mbind() (e.g., returning -EINVAL) rather than silently ignoring it, to avoid confusing userspace that may assume the flag has an effect.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- If MPOL_MF_LAZY is now considered unsupported, consider rejecting it explicitly in do_mbind() (e.g., returning -EINVAL) rather than silently ignoring it, to avoid confusing userspace that may assume the flag has an effect.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Avenger-285714 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
This PR removes unreachable/dead handling for the MPOL_MF_LAZY mbind flag in mempolicy code, and updates the UAPI header comment to indicate the flag is not supported.
Changes:
- Drop
MPOL_MF_LAZY-related dead code paths inmm/mempolicy.c(queue-page walking and mbind policy flag handling). - Update the UAPI comment for
MPOL_MF_LAZYto reduce userspace confusion.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| mm/mempolicy.c | Removes unreachable MPOL_MF_LAZY logic (including an unnecessary change_prot_numa() stub and lazy handling in do_mbind()/page-walk). |
| include/uapi/linux/mempolicy.h | Clarifies via comment that MPOL_MF_LAZY is not supported for mbind. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| to policy */ | ||
| #define MPOL_MF_MOVE_ALL (1<<2) /* Move every page to conform to policy */ | ||
| #define MPOL_MF_LAZY (1<<3) /* Modifies '_MOVE: lazy migrate on fault */ | ||
| #define MPOL_MF_LAZY (1<<3) /* UNSUPPORTED FLAG: Lazy migrate on fault */ |
Summary by Sourcery
Clean up mempolicy NUMA balancing code by removing dead support for the MPOL_MF_LAZY flag and clarifying that the flag is unsupported in the UAPI header.
Enhancements: