Re: [PATCH for-7.5 5/5] memcg: simplify high limit handling after a charge

From: Michal Hocko

Date: Wed Oct 14 2026 - 07:59:08 EST


On Sat 10-10-26 14:09:57, Shakeel Butt wrote:
[...]
> - /* Interrupts, kernel threads, and remote chargers stop here. */
> - if (use_worker)
> + /*
> + * Use a worker for interrupts, kernel threads, and tasks whose mm
> + * does not match the charged hierarchy.
> + */
> + if (use_high_work) {
> + if (!iter)
> + return;
> + if (allow_spinning)
> + schedule_work(&iter->high_work);
> + else
> + irq_work_queue(&iter->high_irq_work);
> return;
> + }
> +
> + if (iter) {

Would it be much simpler to bail out on iter==NULL (i.e. nothing over
high limit) right after the loop?

> + /*
> + * Count the full batch so reclaim work and delay penalties scale
> + * with the pages charged by this task.
> + */
> + current->memcg_nr_pages_over_high += nr_pages;
> + set_notify_resume(current);
> + }
>
> /*
> - * Reclaim is set up above to be called from the userland
> - * return path. But also attempt synchronous reclaim to avoid
> - * excessive overrun while the task is still inside the
> - * kernel. If this is successful, the return path will see it
> - * when it rechecks the overage and simply bail out.
> + * Earlier charges may have left high overage pending even if this charge
> + * found no new overage. Handle it now if this charge can block, to limit
> + * overrun while the task remains in the kernel.
> */
> if (current->memcg_nr_pages_over_high > MEMCG_CHARGE_BATCH &&
> !(current->flags & PF_MEMALLOC) &&
> --
> 2.53.0-Meta

--
Michal Hocko
SUSE Labs