On Thu, Mar 7, 2019 at 1:03 AM Jiri Bohac <jbo...@suse.cz> wrote:
>
> Hi,
>
> On Wed, Mar 06, 2019 at 07:38:59PM +0800, Kairui Song wrote:
> > +int register_mem_pfn_is_ram(int (*fn)(unsigned long pfn))
> > +{
> > +     if (mem_pfn_is_ram)
> > +             return -EBUSY;
> > +     mem_pfn_is_ram = fn;
> > +     return 0;
> > +}
> > +
> > +void unregister_mem_pfn_is_ram(void)
> > +{
> > +     mem_pfn_is_ram = NULL;
> > +}
> > +
> > +static int pfn_is_ram(unsigned long pfn)
> > +{
> > +     if (mem_pfn_is_ram)
> > +             return mem_pfn_is_ram(pfn);
> > +     else
> > +             return 1;
> > +}
> > +
>
> If anyone were ever to use unregister_mem_pfn_is_ram(),
> pfn_is_ram() would become racy.
>
> In V2 you had this:
>         +       fn = mem_pfn_is_ram;
>         +       if (fn)
>         +               ret = fn(pfn);
>
> I agree it's unnecessary since nothing uses
> unregister_mem_pfn_is_ram(). But then I think it would be best to
> just drop the unregister function.
>
> Otherwise the patch looks good to me.
>

Good catch, let me remove the unregister function.
Also, I'd like to have an __init prefix for register_mem_pfn_is_ram,
will update in V5.

--
Best Regards,
Kairui Song

Reply via email to