[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <28395b98-3489-342a-970a-5358e4405f22@linux.ibm.com>
Date: Fri, 6 May 2022 17:35:01 +0200
From: Christian Borntraeger <borntraeger@...ux.ibm.com>
To: Matthew Rosato <mjrosato@...ux.ibm.com>, linux-s390@...r.kernel.org
Cc: alex.williamson@...hat.com, cohuck@...hat.com,
schnelle@...ux.ibm.com, farman@...ux.ibm.com, pmorel@...ux.ibm.com,
hca@...ux.ibm.com, gor@...ux.ibm.com,
gerald.schaefer@...ux.ibm.com, agordeev@...ux.ibm.com,
svens@...ux.ibm.com, frankja@...ux.ibm.com, david@...hat.com,
imbrenda@...ux.ibm.com, vneethv@...ux.ibm.com,
oberpar@...ux.ibm.com, freude@...ux.ibm.com, thuth@...hat.com,
pasic@...ux.ibm.com, pbonzini@...hat.com, corbet@....net,
jgg@...dia.com, kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org
Subject: Re: [PATCH v6 14/21] KVM: s390: pci: provide routines for
enabling/disabling interrupt forwarding
Am 26.04.22 um 22:08 schrieb Matthew Rosato:
[...]
> +static inline void unaccount_mem(unsigned long nr_pages)
> +{
> + struct user_struct *user = get_uid(current_user());
> +
> + if (user)
> + atomic_long_sub(nr_pages, &user->locked_vm);
> + if (current->mm)
> + atomic64_sub(nr_pages, ¤t->mm->pinned_vm);
> +}
> +
> +static inline int account_mem(unsigned long nr_pages)
> +{
> + struct user_struct *user = get_uid(current_user());
> + unsigned long page_limit, cur_pages, new_pages;
> +
> + page_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
> +
> + do {
> + cur_pages = atomic_long_read(&user->locked_vm);
> + new_pages = cur_pages + nr_pages;
> + if (new_pages > page_limit)
> + return -ENOMEM;
> + } while (atomic_long_cmpxchg(&user->locked_vm, cur_pages,
> + new_pages) != cur_pages);
> +
> + atomic64_add(nr_pages, ¤t->mm->pinned_vm);
> +
> + return 0;
user->locked_vm is not available unconditionally. Shall we add
CONFIG_S390 && CONFIG_KVM here?
include/linux/sched/user.h
#if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \
defined(CONFIG_NET) || defined(CONFIG_IO_URING)
atomic_long_t locked_vm;
#endif
Or we could get rid of the user memlock checking for now until this is more ubiquitous.
Otherwise this looks sane
Reviewed-by: Christian Borntraeger <borntraeger@...ux.ibm.com>
Powered by blists - more mailing lists