On Fri, Apr 01, 2022 at 01:14:35PM -0700, Wei Xu wrote: > On Fri, Apr 1, 2022 at 8:22 AM Johannes Weiner <hannes@xxxxxxxxxxx> wrote: > > On Thu, Mar 31, 2022 at 09:05:15PM -0700, Wei Xu wrote: > > > It is better to return an error code (e.g. -EBUSY) when > > > memory_reclaim() fails to reclaim nr_to_reclaim bytes of memory, > > > except if the cgroup memory usage is already 0. We can also return > > > -EINVAL if nr_to_reclaim is too large (e.g. > limit). > > > > For -EBUSY, are you thinking of a specific usecase where that would > > come in handy? I'm not really opposed to it, but couldn't convince > > myself of the practical benefits of it, either. > > > > Keep in mind that MAX_RECLAIM_RETRIES failed reclaim attempts usually > > constitute an OOM situation: memory.max will issue kills and > > memory.high will begin crippling throttling. In what scenario would > > you want to keep reclaiming a workload that is considered OOM? > > > > Certainly, proactive reclaim that wants to purge only the cold tail of > > the workload wouldn't retry. Meta's version of this patch actually > > does return -EAGAIN on reclaim failure, but the userspace daemon > > doesn't do anything with it, so I didn't bring it up. > > -EAGAIN sounds good, too. Given that the userspace requests to > reclaim a specified number of bytes, I think it is generally better to > tell the userspace whether the request has been successfully > fulfilled. Ideally, it would be even better to return how many bytes > that have been reclaimed, though that is not easy to do through the > cgroup interface. The userspace can choose to ignore the return value > or log a message/update some stats (which Google does) for the > monitoring purpose. Fair enough, thanks for your thoughts. No objection from me!