Merge tag 'amd-drm-fixes-5.9-2020-08-20' of git://people.freedesktop.org/~agd5f/linux...
[linux-2.6-microblaze.git] / mm / page_counter.c
index b466384..afe22ad 100644 (file)
@@ -77,8 +77,8 @@ void page_counter_charge(struct page_counter *counter, unsigned long nr_pages)
                 * This is indeed racy, but we can live with some
                 * inaccuracy in the watermark.
                 */
-               if (new > c->watermark)
-                       c->watermark = new;
+               if (new > READ_ONCE(c->watermark))
+                       WRITE_ONCE(c->watermark, new);
        }
 }
 
@@ -119,9 +119,10 @@ bool page_counter_try_charge(struct page_counter *counter,
                        propagate_protected_usage(c, new);
                        /*
                         * This is racy, but we can live with some
-                        * inaccuracy in the failcnt.
+                        * inaccuracy in the failcnt which is only used
+                        * to report stats.
                         */
-                       c->failcnt++;
+                       data_race(c->failcnt++);
                        *fail = c;
                        goto failed;
                }
@@ -130,8 +131,8 @@ bool page_counter_try_charge(struct page_counter *counter,
                 * Just like with failcnt, we can live with some
                 * inaccuracy in the watermark.
                 */
-               if (new > c->watermark)
-                       c->watermark = new;
+               if (new > READ_ONCE(c->watermark))
+                       WRITE_ONCE(c->watermark, new);
        }
        return true;