* [PATCH] memcg: replace in_interrupt() with !in_task()
@ 2022-01-27 16:26 Shakeel Butt
2022-01-28 12:23 ` Michal Hocko
0 siblings, 1 reply; 3+ messages in thread
From: Shakeel Butt @ 2022-01-27 16:26 UTC (permalink / raw)
To: Vasily Averin, Johannes Weiner, Michal Hocko, Roman Gushchin
Cc: Andrew Morton, linux-mm, linux-kernel, Shakeel Butt
Replace the deprecated in_interrupt() with !in_task() because
in_interrupt() returns true for BH disabled even if the call happens in
the task context. in_task() is the right interface to differentiate
task context from NMI, hard IRQ and softirq contexts.
Signed-off-by: Shakeel Butt <shakeelb@google.com>
---
mm/memcontrol.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d067366002e6..215dfe325e9d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2688,7 +2688,7 @@ static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,
READ_ONCE(memcg->swap.high);
/* Don't bother a random interrupted task */
- if (in_interrupt()) {
+ if (!in_task()) {
if (mem_high) {
schedule_work(&memcg->high_work);
break;
@@ -6968,7 +6968,7 @@ void mem_cgroup_sk_alloc(struct sock *sk)
return;
/* Do not associate the sock with unrelated interrupted task's memcg. */
- if (in_interrupt())
+ if (!in_task())
return;
rcu_read_lock();
--
2.35.0.rc0.227.g00780c9af4-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] memcg: replace in_interrupt() with !in_task()
2022-01-27 16:26 [PATCH] memcg: replace in_interrupt() with !in_task() Shakeel Butt
@ 2022-01-28 12:23 ` Michal Hocko
2022-01-28 16:20 ` Shakeel Butt
0 siblings, 1 reply; 3+ messages in thread
From: Michal Hocko @ 2022-01-28 12:23 UTC (permalink / raw)
To: Shakeel Butt
Cc: Vasily Averin, Johannes Weiner, Roman Gushchin, Andrew Morton,
linux-mm, linux-kernel
On Thu 27-01-22 08:26:36, Shakeel Butt wrote:
> Replace the deprecated in_interrupt() with !in_task() because
> in_interrupt() returns true for BH disabled even if the call happens in
> the task context. in_task() is the right interface to differentiate
> task context from NMI, hard IRQ and softirq contexts.
Makes sense. I do not think this will have any visible effect. Except
for removing a deprecated call, right?
> Signed-off-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Thanks!
> ---
> mm/memcontrol.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index d067366002e6..215dfe325e9d 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2688,7 +2688,7 @@ static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,
> READ_ONCE(memcg->swap.high);
>
> /* Don't bother a random interrupted task */
> - if (in_interrupt()) {
> + if (!in_task()) {
> if (mem_high) {
> schedule_work(&memcg->high_work);
> break;
> @@ -6968,7 +6968,7 @@ void mem_cgroup_sk_alloc(struct sock *sk)
> return;
>
> /* Do not associate the sock with unrelated interrupted task's memcg. */
> - if (in_interrupt())
> + if (!in_task())
> return;
>
> rcu_read_lock();
> --
> 2.35.0.rc0.227.g00780c9af4-goog
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] memcg: replace in_interrupt() with !in_task()
2022-01-28 12:23 ` Michal Hocko
@ 2022-01-28 16:20 ` Shakeel Butt
0 siblings, 0 replies; 3+ messages in thread
From: Shakeel Butt @ 2022-01-28 16:20 UTC (permalink / raw)
To: Michal Hocko
Cc: Vasily Averin, Johannes Weiner, Roman Gushchin, Andrew Morton,
Linux MM, LKML
On Fri, Jan 28, 2022 at 4:23 AM Michal Hocko <mhocko@suse.com> wrote:
>
> On Thu 27-01-22 08:26:36, Shakeel Butt wrote:
> > Replace the deprecated in_interrupt() with !in_task() because
> > in_interrupt() returns true for BH disabled even if the call happens in
> > the task context. in_task() is the right interface to differentiate
> > task context from NMI, hard IRQ and softirq contexts.
>
> Makes sense. I do not think this will have any visible effect. Except
> for removing a deprecated call, right?
Correct, that is my understanding as well.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-28 16:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-27 16:26 [PATCH] memcg: replace in_interrupt() with !in_task() Shakeel Butt
2022-01-28 12:23 ` Michal Hocko
2022-01-28 16:20 ` Shakeel Butt
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).