Merge tag 'pwm/for-5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry...
[linux-2.6-microblaze.git] / mm / page_counter.c
index c6860f5..7d83641 100644 (file)
@@ -52,9 +52,13 @@ void page_counter_cancel(struct page_counter *counter, unsigned long nr_pages)
        long new;
 
        new = atomic_long_sub_return(nr_pages, &counter->usage);
-       propagate_protected_usage(counter, new);
        /* More uncharges than charges? */
-       WARN_ON_ONCE(new < 0);
+       if (WARN_ONCE(new < 0, "page_counter underflow: %ld nr_pages=%lu\n",
+                     new, nr_pages)) {
+               new = 0;
+               atomic_long_set(&counter->usage, new);
+       }
+       propagate_protected_usage(counter, new);
 }
 
 /**