lkml.org 
[lkml]   [2020]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH bpf-next v5 06/34] bpf: prepare for memcg-based memory accounting for bpf maps
Date


> On Nov 12, 2020, at 2:15 PM, Roman Gushchin <guro@fb.com> wrote:

[...]

>
> +#ifdef CONFIG_MEMCG_KMEM
> +static __always_inline int __bpf_map_update_elem(struct bpf_map *map, void *key,
> + void *value, u64 flags)
> +{
> + struct mem_cgroup *old_memcg;
> + bool in_interrupt;
> + int ret;
> +
> + /*
> + * If update from an interrupt context results in a memory allocation,
> + * the memory cgroup to charge can't be determined from the context
> + * of the current task. Instead, we charge the memory cgroup, which
> + * contained a process created the map.
> + */
> + in_interrupt = in_interrupt();
> + if (in_interrupt)
> + old_memcg = set_active_memcg(map->memcg);

set_active_memcg() checks in_interrupt() again. Maybe we can introduce another
helper to avoid checking it twice? Something like

static inline struct mem_cgroup *
set_active_memcg_int(struct mem_cgroup *memcg)
{
struct mem_cgroup *old;

old = this_cpu_read(int_active_memcg);
this_cpu_write(int_active_memcg, memcg);
return old;
}

Thanks,
Song

[...]
\
 
 \ /
  Last update: 2020-11-13 18:48    [W:1.167 / U:1.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site