linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: zhangyiru <zhangyiru3@huawei.com>
Cc: mike.kravetz@oracle.com, akpm@linux-foundation.org,
	linux-mm@kvack.org,  mhocko@suse.com, wuxu.wu@huawei.com,
	liusirui@huawei.com,  liuzixian4@huawei.com
Subject: Re: [PATCH v4] mm,hugetlb: remove mlock ulimit for SHM_HUGETLB
Date: Mon, 1 Nov 2021 00:01:48 -0700 (PDT)	[thread overview]
Message-ID: <17d4c5c5-af74-c6d1-f05d-1c2078c2d6a@google.com> (raw)
In-Reply-To: <20211009094355.127705-1-zhangyiru3@huawei.com>

On Sat, 9 Oct 2021, zhangyiru wrote:

> commit 21a3c273f88c9cbbaf7e ("mm, hugetlb: add thread name and pid to
> SHM_HUGETLB mlock rlimit warning") marked this as deprecated in 2012,
> but it is not deleted yet.
> 
> Mike says he still see that message in log files on occasion,
> so maybe we should preserve this warning.
> 
> Signed-off-by: zhangyiru <zhangyiru3@huawei.com>
> ---
> Changelog:
>  v4: modify context information of obsolete
>  v3: modify warning message to obsolete
>  v2: preserve warning message
>  v1: remove mlock ulimit for SHM_HUGETLB
> ---
>  fs/hugetlbfs/inode.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index cdfb1ae78a3f..5ff3418759ed 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -1467,13 +1467,12 @@ struct file *hugetlb_file_setup(const char *name, size_t size,
>  		*ucounts = current_ucounts();
>  		if (user_shm_lock(size, *ucounts)) {
>  			task_lock(current);
> -			pr_warn_once("%s (%d): Using mlock ulimits for SHM_HUGETLB is deprecated\n",
> +			pr_warn_once("%s (%d): Using mlock ulimits for SHM_HUGETLB is obsolete\n",
>  				current->comm, current->pid);
>  			task_unlock(current);
> -		} else {
> -			*ucounts = NULL;
> -			return ERR_PTR(-EPERM);
>  		}
> +		*ucounts = NULL;
> +		return ERR_PTR(-EPERM);
>  	}
>  
>  	file = ERR_PTR(-ENOSPC);
> -- 
> 2.27.0

I have nothing against the obsoletion itself;
but this patch appears to be incorrect, and far from complete.

Incorrect (unless we actually want to *punish* those who still use
deprecated interfaces) because in these latest versions, it consumes
from the mlock ulimit (if use_shm_lock() succeeds), but never gives
back what it consumed.  I don't see why user_shm_lock() is called.

Incomplete, because further down (at the "out" label) there's
a pointless call to user_shm_unlock(), which should be removed.

Far from complete, because why is there even a ucounts argument to
hugetlb_file_setup() now?  That should be removed too, and ipc/shm.c
adjusted (but it still needs shp->mlock_ucounts for the shmem case).

(Sorry, I'm being totally unresponsive at present, needing to focus
on something else; but thought I'd better get these comments in before
mmotm's mmhugetlb-remove-mlock-ulimit-for-shm_hugetlb.patch goes to 5.16.)

Hugh


  parent reply	other threads:[~2021-11-01  7:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-09  9:43 [PATCH v4] mm,hugetlb: remove mlock ulimit for SHM_HUGETLB zhangyiru
2021-10-11 21:39 ` Mike Kravetz
2021-11-01  7:01 ` Hugh Dickins [this message]
2021-11-01 19:44   ` [PATCH v5] " zhangyiru
2021-11-01 21:09     ` [PATCH v6] " zhangyiru
2021-11-01 23:05       ` Mike Kravetz
2021-11-02 15:40         ` [PATCH v7] " zhangyiru
2021-11-02 19:46           ` Mike Kravetz
2021-11-03 10:58             ` [PATCH v8] " zhangyiru
2021-11-03 17:19               ` Mike Kravetz
2021-11-01 21:39   ` [PATCH v4] " Mike Kravetz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17d4c5c5-af74-c6d1-f05d-1c2078c2d6a@google.com \
    --to=hughd@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=liusirui@huawei.com \
    --cc=liuzixian4@huawei.com \
    --cc=mhocko@suse.com \
    --cc=mike.kravetz@oracle.com \
    --cc=wuxu.wu@huawei.com \
    --cc=zhangyiru3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).