On Mon, 13 Jul 2020 10:41:39 +0200 SeongJae Park <sjpark@xxxxxxxxxx> wrote: > From: SeongJae Park <sjpark@xxxxxxxxx> > > This commit implements a debugfs interface for DAMON. It works for the > virtual address spaces monitoring. > [...] > +/* > + * Converts a string into an array of unsigned long integers > + * > + * Returns an array of unsigned long integers if the conversion success, or > + * NULL otherwise. > + */ > +static int *str_to_pids(const char *str, ssize_t len, ssize_t *nr_pids) > +{ > + int *pids; > + const int max_nr_pids = 32; > + int pid; > + int pos = 0, parsed, ret; > + > + *nr_pids = 0; > + pids = kmalloc_array(max_nr_pids, sizeof(pid), GFP_KERNEL); > + if (!pids) > + return NULL; > + while (*nr_pids < max_nr_pids && pos < len) { > + ret = sscanf(&str[pos], "%d%n", &pid, &parsed); > + pos += parsed; > + if (ret != 1) > + break; > + pids[*nr_pids] = pid; > + *nr_pids += 1; > + } > + if (*nr_pids == 0) { > + kfree(pids); > + pids = NULL; > + } Hmm, this means debugfs users cannot make 'target_ids' empty again. I will fix this in the next spin. Thanks, SeongJae Park