]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blobdiff - mm/page_counter.c
bpf: Add classid helper only based on skb->sk
[mirror_ubuntu-hirsute-kernel.git] / mm / page_counter.c
index b4663844c9b3740d2c26c4298e882d00b5ec998f..afe22ad335ccc2a0be5a3ee3514d97e46ee1bddd 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;