bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH gnumach v2] Implement per task virtual memory limit


From: Diego Nieto Cid
Subject: Re: [PATCH gnumach v2] Implement per task virtual memory limit
Date: Sat, 4 Jan 2025 16:36:13 +0000

Hello,

On Wed, Dec 25, 2024 at 04:16:06PM -0300, dnietoc@gmail.com wrote:
>
> +/*
> + *     Enforces the VM limit of a target map.
> + */
> +static kern_return_t
> +vm_map_enforce_limit(
> +     vm_map_t map,
> +     vm_size_t size,
> +     const char *fn_name)
> +{
> +     /* Limit is ignored for the kernel map */
> +     if (vm_map_pmap(map) == kernel_pmap) {
> +             return KERN_SUCCESS;
> +     }
> +
> +     /* Avoid taking into account the total VM_PROT_NONE virtual memory */
> +     vm_size_t usable_size = map->size - map->size_none;
> +     vm_size_t new_size = size + usable_size;
> +     /* Check for integer overflow */
> +     if (new_size < size) {
> +             return KERN_INVALID_ARGUMENT;
> +     }
> +
> +     if (new_size > map->size_cur_limit) {
> +             task_t task = current_task();
> +             printf("[%s] [task %s] map size: %lu, none: %lu, requested: 
> %lu, limit: %lu\n",
> +                     fn_name, task->name, map->size, map->size_none, size, 
> map->size_cur_limit);

Should I drop the printf here now that vm_map_print also prints this 
information?

--
Diego



reply via email to

[Prev in Thread] Current Thread [Next in Thread]