)]}'
{
  "commit": "4f08f4910290e9b62bbc993513fd9331c95f3dee",
  "tree": "3ffa3c320c10b307556f1a28e6064959ca42d03f",
  "parents": [
    "1b0fe213722c84318d308a07277d653872eb07fb"
  ],
  "author": {
    "name": "David Hildenbrand",
    "email": "david@redhat.com",
    "time": "Mon Apr 06 20:05:22 2020 -0700"
  },
  "committer": {
    "name": "COS Cherry Picker",
    "email": "cloud-image-release@prod.google.com",
    "time": "Thu May 27 12:30:57 2021 -0700"
  },
  "message": "virtio-balloon: switch back to OOM handler for VIRTIO_BALLOON_F_DEFLATE_ON_OOM\n\nCommit 71994620bb25 (\"virtio_balloon: replace oom notifier with shrinker\")\nchanged the behavior when deflation happens automatically.  Instead of\ndeflating when called by the OOM handler, the shrinker is used.\n\nHowever, the balloon is not simply some other slab cache that should be\nshrunk when under memory pressure.  The shrinker does not have a concept\nof priorities yet, so this behavior cannot be configured.  Eventually once\nthat is in place, we might want to switch back after doing proper testing.\n\nThere was a report that this results in undesired side effects when\ninflating the balloon to shrink the page cache. [1]\n\t\"When inflating the balloon against page cache (i.e. no free memory\n\t remains) vmscan.c will both shrink page cache, but also invoke the\n\t shrinkers -- including the balloon\u0027s shrinker. So the balloon\n\t driver allocates memory which requires reclaim, vmscan gets this\n\t memory by shrinking the balloon, and then the driver adds the\n\t memory back to the balloon. Basically a busy no-op.\"\n\nThe name \"deflate on OOM\" makes it pretty clear when deflation should\nhappen - after other approaches to reclaim memory failed, not while\nreclaiming. This allows to minimize the footprint of a guest - memory\nwill only be taken out of the balloon when really needed.\n\nKeep using the shrinker for VIRTIO_BALLOON_F_FREE_PAGE_HINT, because\nthis has no such side effects. Always register the shrinker with\nVIRTIO_BALLOON_F_FREE_PAGE_HINT now. We are always allowed to reuse free\npages that are still to be processed by the guest. The hypervisor takes\ncare of identifying and resolving possible races between processing a\nhinting request and the guest reusing a page.\n\nIn contrast to pre commit 71994620bb25 (\"virtio_balloon: replace oom\nnotifier with shrinker\"), don\u0027t add a module parameter to configure the\nnumber of pages to deflate on OOM. Can be re-added if really needed.\nAlso, pay attention that leak_balloon() returns the number of 4k pages -\nconvert it properly in virtio_balloon_oom_notify().\n\nTesting done by Tyler for future reference:\n  Test setup: VM with 16 CPU, 64GB RAM. Running Debian 10. We have a 42\n  GB file full of random bytes that we continually cat to /dev/null.\n  This fills the page cache as the file is read. Meanwhile, we trigger\n  the balloon to inflate, with a target size of 53 GB. This setup causes\n  the balloon inflation to pressure the page cache as the page cache is\n  also trying to grow. Afterwards we shrink the balloon back to zero (so\n  total deflate \u003d\u003d total inflate).\n\n  Without this patch (kernel 4.19.0-5):\n  Inflation never reaches the target until we stop the \"cat file \u003e\n  /dev/null\" process. Total inflation time was 542 seconds. The longest\n  period that made no net forward progress was 315 seconds.\n    Result of \"grep balloon /proc/vmstat\" after the test:\n    balloon_inflate 154828377\n    balloon_deflate 154828377\n\n  With this patch (kernel 5.6.0-rc4+):\n  Total inflation duration was 63 seconds. No deflate-queue activity\n  occurs when pressuring the page-cache.\n    Result of \"grep balloon /proc/vmstat\" after the test:\n    balloon_inflate 12968539\n    balloon_deflate 12968539\n\n  Conclusion: This patch fixes the issue.  In the test it reduced\n  inflate/deflate activity by 12x, and reduced inflation time by 8.6x.\n  But more importantly, if we hadn\u0027t killed the \"cat file \u003e /dev/null\"\n  process then, without the patch, the inflation process would never reach\n  the target.\n\n[1] https://www.spinics.net/lists/linux-virtualization/msg40863.html\n\nBUG\u003db/173726314\nTEST\u003dpresubmit, manual test as described in the commit message\nRELEASE_NOTE\u003dImprove CPU usage for certain workloads with heavy page cache usage\nSOURCE\u003dUPSTREAM(da10329cb057e49be7f099eb7864d16f7705f798)\n\ncos-patch: bug\nLink: http://lkml.kernel.org/r/20200311135523.18512-2-david@redhat.com\nFixes: 71994620bb25 (\"virtio_balloon: replace oom notifier with shrinker\")\nSigned-off-by: David Hildenbrand \u003cdavid@redhat.com\u003e\nReported-by: Tyler Sanderson \u003ctysand@google.com\u003e\nTested-by: Tyler Sanderson \u003ctysand@google.com\u003e\nAcked-by: David Rientjes \u003crientjes@google.com\u003e\nAcked-by: Michael S. Tsirkin \u003cmst@redhat.com\u003e\nCc: Wei Wang \u003cwei.w.wang@intel.com\u003e\nCc: Alexander Duyck \u003calexander.h.duyck@linux.intel.com\u003e\nCc: David Rientjes \u003crientjes@google.com\u003e\nCc: Nadav Amit \u003cnamit@vmware.com\u003e\nCc: Michal Hocko \u003cmhocko@kernel.org\u003e\nSigned-off-by: Andrew Morton \u003cakpm@linux-foundation.org\u003e\nSigned-off-by: Linus Torvalds \u003ctorvalds@linux-foundation.org\u003e\n(cherry picked from commit da10329cb057e49be7f099eb7864d16f7705f798)\nChange-Id: I3868a66f701ed594dc4c5f3ee985efea8ac5649e\nReviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/16230\nReviewed-by: Vaibhav Rustagi \u003cvaibhavrustagi@google.com\u003e\nReviewed-by: Roy Yang \u003croyyang@google.com\u003e\nTested-by: Cusky Presubmit Bot \u003cpresubmit@cos-infra-prod.iam.gserviceaccount.com\u003e\n(cherry picked from commit 47b0ae241be71d51b875c5f22b0b7950277e67f5)\nReviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/16832\nMain-Branch-Verified: Cusky Presubmit Bot \u003cpresubmit@cos-infra-prod.iam.gserviceaccount.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "1e444826a66e91ebb9ac0159b2f5e2a55d2fc560",
      "old_mode": 33188,
      "old_path": "drivers/virtio/virtio_balloon.c",
      "new_id": "fb86ab87caabbdf72f7898d03e25bae457dc4e52",
      "new_mode": 33188,
      "new_path": "drivers/virtio/virtio_balloon.c"
    }
  ]
}
