]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - include/linux/memcontrol.h
net: tcp_memcontrol: remove dead per-memcg count of allocated sockets
[karo-tx-linux.git] / include / linux / memcontrol.h
index cd0e2413c358d4cf58072ebbdc2cfea2684fd245..15acc04ebdd38ec994feac9a515c4004425ac37e 100644 (file)
@@ -85,22 +85,11 @@ enum mem_cgroup_events_target {
        MEM_CGROUP_NTARGETS,
 };
 
-/*
- * Bits in struct cg_proto.flags
- */
-enum cg_proto_flags {
-       /* Currently active and new sockets should be assigned to cgroups */
-       MEMCG_SOCK_ACTIVE,
-       /* It was ever activated; we must disarm static keys on destruction */
-       MEMCG_SOCK_ACTIVATED,
-};
-
 struct cg_proto {
        struct page_counter     memory_allocated;       /* Current allocated memory. */
-       struct percpu_counter   sockets_allocated;      /* Current number of sockets. */
        int                     memory_pressure;
+       bool                    active;
        long                    sysctl_mem[3];
-       unsigned long           flags;
        /*
         * memcg field is used to find which memcg we belong directly
         * Each memcg struct can hold more than one cg_proto, so container_of
@@ -275,7 +264,8 @@ struct mem_cgroup {
        struct mem_cgroup_per_node *nodeinfo[0];
        /* WARNING: nodeinfo must be the last member here */
 };
-extern struct cgroup_subsys_state *mem_cgroup_root_css;
+
+extern struct mem_cgroup *root_mem_cgroup;
 
 /**
  * mem_cgroup_events - count memory events against a cgroup
@@ -703,17 +693,8 @@ static inline void mem_cgroup_wb_stats(struct bdi_writeback *wb,
 #endif /* CONFIG_CGROUP_WRITEBACK */
 
 struct sock;
-#if defined(CONFIG_INET) && defined(CONFIG_MEMCG_KMEM)
 void sock_update_memcg(struct sock *sk);
 void sock_release_memcg(struct sock *sk);
-#else
-static inline void sock_update_memcg(struct sock *sk)
-{
-}
-static inline void sock_release_memcg(struct sock *sk)
-{
-}
-#endif /* CONFIG_INET && CONFIG_MEMCG_KMEM */
 
 #ifdef CONFIG_MEMCG_KMEM
 extern struct static_key memcg_kmem_enabled_key;
@@ -766,15 +747,13 @@ static inline int memcg_cache_id(struct mem_cgroup *memcg)
        return memcg ? memcg->kmemcg_id : -1;
 }
 
-struct kmem_cache *__memcg_kmem_get_cache(struct kmem_cache *cachep);
+struct kmem_cache *__memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp);
 void __memcg_kmem_put_cache(struct kmem_cache *cachep);
 
-static inline bool __memcg_kmem_bypass(gfp_t gfp)
+static inline bool __memcg_kmem_bypass(void)
 {
        if (!memcg_kmem_enabled())
                return true;
-       if (gfp & __GFP_NOACCOUNT)
-               return true;
        if (in_interrupt() || (!current->mm) || (current->flags & PF_KTHREAD))
                return true;
        return false;
@@ -791,7 +770,9 @@ static inline bool __memcg_kmem_bypass(gfp_t gfp)
 static __always_inline int memcg_kmem_charge(struct page *page,
                                             gfp_t gfp, int order)
 {
-       if (__memcg_kmem_bypass(gfp))
+       if (__memcg_kmem_bypass())
+               return 0;
+       if (!(gfp & __GFP_ACCOUNT))
                return 0;
        return __memcg_kmem_charge(page, gfp, order);
 }
@@ -810,16 +791,15 @@ static __always_inline void memcg_kmem_uncharge(struct page *page, int order)
 /**
  * memcg_kmem_get_cache: selects the correct per-memcg cache for allocation
  * @cachep: the original global kmem cache
- * @gfp: allocation flags.
  *
  * All memory allocated from a per-memcg cache is charged to the owner memcg.
  */
 static __always_inline struct kmem_cache *
 memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp)
 {
-       if (__memcg_kmem_bypass(gfp))
+       if (__memcg_kmem_bypass())
                return cachep;
-       return __memcg_kmem_get_cache(cachep);
+       return __memcg_kmem_get_cache(cachep, gfp);
 }
 
 static __always_inline void memcg_kmem_put_cache(struct kmem_cache *cachep)