@@ -236,10 +236,6 @@ struct cgroup_event {
236
236
* css which the event belongs to.
237
237
*/
238
238
struct cgroup_subsys_state * css ;
239
- /*
240
- * Control file which the event associated.
241
- */
242
- struct cftype * cft ;
243
239
/*
244
240
* eventfd to signal userspace about the event.
245
241
*/
@@ -254,15 +250,13 @@ struct cgroup_event {
254
250
* on eventfd to send notification to userspace.
255
251
*/
256
252
int (* register_event )(struct cgroup_subsys_state * css ,
257
- struct cftype * cft , struct eventfd_ctx * eventfd ,
258
- const char * args );
253
+ struct eventfd_ctx * eventfd , const char * args );
259
254
/*
260
255
* unregister_event() callback will be called when userspace closes
261
256
* the eventfd or on cgroup removing. This callback must be set,
262
257
* if you want provide notification functionality.
263
258
*/
264
259
void (* unregister_event )(struct cgroup_subsys_state * css ,
265
- struct cftype * cft ,
266
260
struct eventfd_ctx * eventfd );
267
261
/*
268
262
* All fields below needed to unregister event when
@@ -5688,13 +5682,12 @@ static void mem_cgroup_oom_notify(struct mem_cgroup *memcg)
5688
5682
mem_cgroup_oom_notify_cb (iter );
5689
5683
}
5690
5684
5691
- static int mem_cgroup_usage_register_event (struct cgroup_subsys_state * css ,
5692
- struct cftype * cft , struct eventfd_ctx * eventfd , const char * args )
5685
+ static int __mem_cgroup_usage_register_event (struct cgroup_subsys_state * css ,
5686
+ struct eventfd_ctx * eventfd , const char * args , enum res_type type )
5693
5687
{
5694
5688
struct mem_cgroup * memcg = mem_cgroup_from_css (css );
5695
5689
struct mem_cgroup_thresholds * thresholds ;
5696
5690
struct mem_cgroup_threshold_ary * new ;
5697
- enum res_type type = MEMFILE_TYPE (cft -> private );
5698
5691
u64 threshold , usage ;
5699
5692
int i , size , ret ;
5700
5693
@@ -5771,13 +5764,24 @@ static int mem_cgroup_usage_register_event(struct cgroup_subsys_state *css,
5771
5764
return ret ;
5772
5765
}
5773
5766
5774
- static void mem_cgroup_usage_unregister_event (struct cgroup_subsys_state * css ,
5775
- struct cftype * cft , struct eventfd_ctx * eventfd )
5767
+ static int mem_cgroup_usage_register_event (struct cgroup_subsys_state * css ,
5768
+ struct eventfd_ctx * eventfd , const char * args )
5769
+ {
5770
+ return __mem_cgroup_usage_register_event (css , eventfd , args , _MEM );
5771
+ }
5772
+
5773
+ static int memsw_cgroup_usage_register_event (struct cgroup_subsys_state * css ,
5774
+ struct eventfd_ctx * eventfd , const char * args )
5775
+ {
5776
+ return __mem_cgroup_usage_register_event (css , eventfd , args , _MEMSWAP );
5777
+ }
5778
+
5779
+ static void __mem_cgroup_usage_unregister_event (struct cgroup_subsys_state * css ,
5780
+ struct eventfd_ctx * eventfd , enum res_type type )
5776
5781
{
5777
5782
struct mem_cgroup * memcg = mem_cgroup_from_css (css );
5778
5783
struct mem_cgroup_thresholds * thresholds ;
5779
5784
struct mem_cgroup_threshold_ary * new ;
5780
- enum res_type type = MEMFILE_TYPE (cft -> private );
5781
5785
u64 usage ;
5782
5786
int i , j , size ;
5783
5787
@@ -5850,14 +5854,24 @@ static void mem_cgroup_usage_unregister_event(struct cgroup_subsys_state *css,
5850
5854
mutex_unlock (& memcg -> thresholds_lock );
5851
5855
}
5852
5856
5857
+ static void mem_cgroup_usage_unregister_event (struct cgroup_subsys_state * css ,
5858
+ struct eventfd_ctx * eventfd )
5859
+ {
5860
+ return __mem_cgroup_usage_unregister_event (css , eventfd , _MEM );
5861
+ }
5862
+
5863
+ static void memsw_cgroup_usage_unregister_event (struct cgroup_subsys_state * css ,
5864
+ struct eventfd_ctx * eventfd )
5865
+ {
5866
+ return __mem_cgroup_usage_unregister_event (css , eventfd , _MEMSWAP );
5867
+ }
5868
+
5853
5869
static int mem_cgroup_oom_register_event (struct cgroup_subsys_state * css ,
5854
- struct cftype * cft , struct eventfd_ctx * eventfd , const char * args )
5870
+ struct eventfd_ctx * eventfd , const char * args )
5855
5871
{
5856
5872
struct mem_cgroup * memcg = mem_cgroup_from_css (css );
5857
5873
struct mem_cgroup_eventfd_list * event ;
5858
- enum res_type type = MEMFILE_TYPE (cft -> private );
5859
5874
5860
- BUG_ON (type != _OOM_TYPE );
5861
5875
event = kmalloc (sizeof (* event ), GFP_KERNEL );
5862
5876
if (!event )
5863
5877
return - ENOMEM ;
@@ -5876,13 +5890,10 @@ static int mem_cgroup_oom_register_event(struct cgroup_subsys_state *css,
5876
5890
}
5877
5891
5878
5892
static void mem_cgroup_oom_unregister_event (struct cgroup_subsys_state * css ,
5879
- struct cftype * cft , struct eventfd_ctx * eventfd )
5893
+ struct eventfd_ctx * eventfd )
5880
5894
{
5881
5895
struct mem_cgroup * memcg = mem_cgroup_from_css (css );
5882
5896
struct mem_cgroup_eventfd_list * ev , * tmp ;
5883
- enum res_type type = MEMFILE_TYPE (cft -> private );
5884
-
5885
- BUG_ON (type != _OOM_TYPE );
5886
5897
5887
5898
spin_lock (& memcg_oom_lock );
5888
5899
@@ -6012,7 +6023,7 @@ static void cgroup_event_remove(struct work_struct *work)
6012
6023
6013
6024
remove_wait_queue (event -> wqh , & event -> wait );
6014
6025
6015
- event -> unregister_event (css , event -> cft , event -> eventfd );
6026
+ event -> unregister_event (css , event -> eventfd );
6016
6027
6017
6028
/* Notify userspace the event is going away. */
6018
6029
eventfd_signal (event -> eventfd , 1 );
@@ -6133,12 +6144,6 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *css,
6133
6144
if (ret < 0 )
6134
6145
goto out_put_cfile ;
6135
6146
6136
- event -> cft = __file_cft (cfile .file );
6137
- if (IS_ERR (event -> cft )) {
6138
- ret = PTR_ERR (event -> cft );
6139
- goto out_put_cfile ;
6140
- }
6141
-
6142
6147
/*
6143
6148
* Determine the event callbacks and set them in @event. This used
6144
6149
* to be done via struct cftype but cgroup core no longer knows
@@ -6157,8 +6162,8 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *css,
6157
6162
event -> register_event = vmpressure_register_event ;
6158
6163
event -> unregister_event = vmpressure_unregister_event ;
6159
6164
} else if (!strcmp (name , "memory.memsw.usage_in_bytes" )) {
6160
- event -> register_event = mem_cgroup_usage_register_event ;
6161
- event -> unregister_event = mem_cgroup_usage_unregister_event ;
6165
+ event -> register_event = memsw_cgroup_usage_register_event ;
6166
+ event -> unregister_event = memsw_cgroup_usage_unregister_event ;
6162
6167
} else {
6163
6168
ret = - EINVAL ;
6164
6169
goto out_put_cfile ;
@@ -6181,7 +6186,7 @@ static int cgroup_write_event_control(struct cgroup_subsys_state *css,
6181
6186
if (ret )
6182
6187
goto out_put_cfile ;
6183
6188
6184
- ret = event -> register_event (css , event -> cft , event -> eventfd , buffer );
6189
+ ret = event -> register_event (css , event -> eventfd , buffer );
6185
6190
if (ret )
6186
6191
goto out_put_css ;
6187
6192
0 commit comments