On Fri, 13 Mar 2020 21:16:49 +0100 SeongJae Park <sj38.park@xxxxxxxxx> wrote: > On Fri, 13 Mar 2020 17:29:54 +0000 Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> wrote: > > > On Mon, 24 Feb 2020 13:30:35 +0100 > > SeongJae Park <sjpark@xxxxxxxxxx> wrote: > > > > > From: SeongJae Park <sjpark@xxxxxxxxx> > > > > > > This commit implements DAMON's basic access check and region based > > > sampling mechanisms. This change would seems make no sense, mainly > > > because it is only a part of the DAMON's logics. Following two commits > > > will make more sense. > > > > [...] > > > > Came across a minor issue inline. kthread_run calls kthread_create. > > That gives a potential sleep while atomic issue given the spin lock. > > > > Can probably be fixed by preallocating the thread then starting it later. > > > > Jonathan > [...] > > > +/* > > > + * Start or stop the kdamond > > > + * > > > + * Returns 0 if success, negative error code otherwise. > > > + */ > > > +static int damon_turn_kdamond(struct damon_ctx *ctx, bool on) > > > +{ > > > + spin_lock(&ctx->kdamond_lock); > > > + ctx->kdamond_stop = !on; > > > + if (!ctx->kdamond && on) { > > > + ctx->kdamond = kthread_run(kdamond_fn, ctx, "kdamond"); > > > > Can't do this under a spin lock. > > Good catch! And, agree to your suggestion. I will fix this in that way! I changed my mind. I would like to simply use mutex instead of spinlock, as khugepaged also does. If you have different opinion, please let me know. Thanks, SeongJae Park > > > Thanks, > SeongJae Park