On Fri, Dec 14, 2018 at 11:02:32AM +0100, Petr Mladek wrote: > On Thu 2018-12-13 16:46:25, Josh Poimboeuf wrote: > > Now that we can't re-enable a patch, I wonder if we really need both the > > 'patch->enabled' and 'klp_target_state' variables? > > > > A patch is now always enabled, unless it's in transition, in which case > > its 'enabled' state is the same as 'klp_target_state'. > > > > For example I wonder if we could get rid of 'klp_target_state', since it > > should be the same as 'klp_transition_patch->enabled'. > > There are some catches: > > 1. klp_update_patch_state() can be called anywhere and anytime. We > would add yet another race-sensitive code if we access the flag > via a pointer. True. > 2. patch->enabled is bool while klp_target_state is triple state. > The argument is that KLP_UNDEFINED helps to catch bugs. > > > > Or alternatively we could get rid of 'patch->enabled', since it should > > be the same as > > > > patch == klp_transition_patch ? klp_target_state : true > > This might solve the first catch but not the 2nd one. It could WARN_ON if it's KLP_UNDEFINED when it's not supposed to be. > Not to say that it is much harder to read. We could put it in a klp_patch_enabled(patch) wrapper. > > Of course this could be a follow-on cleanup patch, which could be done > > in the future, so as not to hold up the merging of these patches > > anymore. > > Yes, please. This is controversial, non-trivial, and can wait. No problem. -- Josh