Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261324AbTH2PEN (ORCPT ); Fri, 29 Aug 2003 11:04:13 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261306AbTH2PCL (ORCPT ); Fri, 29 Aug 2003 11:02:11 -0400 Received: from web12802.mail.yahoo.com ([216.136.174.37]:21114 "HELO web12802.mail.yahoo.com") by vger.kernel.org with SMTP id S261292AbTH2PBN (ORCPT ); Fri, 29 Aug 2003 11:01:13 -0400 Message-ID: <20030829150111.72151.qmail@web12802.mail.yahoo.com> Date: Fri, 29 Aug 2003 08:01:11 -0700 (PDT) From: Shantanu Goel Subject: [VM PATCH] Faster reclamation of dirty pages and unused inode/dcache entries in 2.4.22 To: linux-kernel@vger.kernel.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="0-827563270-1062169271=:72021" Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6382 Lines: 126 --0-827563270-1062169271=:72021 Content-Type: text/plain; charset=us-ascii Content-Id: Content-Disposition: inline Hi kernel hackers, The VM subsystem in Linux 2.4.22 can cause spurious swapouts in the presence of lots of dirty pages. Presently, as dirty pages are encountered, shrink_cache() schedules a writepage() and moves the page to the head of the inactive list. When a lot of dirty pages are present, this can break the FIFO ordering of the inactive list because clean pages further down the list will be reclaimed first. The following patch records the pages being laundered, and once SWAP_CLUSTER_MAX pages have been accumulated or the scan is complete, goes back and attempts to move them back to the tail of the list. The second part of the patch reclaims unused inode/dentry/dquot entries more aggressively. I have observed that on an NFS server where swap out activity is low, the VM can shrink the page cache to the point where most pages are used up by unused inode/dentry entries. This is because page cache reclamation succeeds most of the time except when a swap_out() happens. Feedback and comments are welcome. Thanks, Shantanu Goel __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com --0-827563270-1062169271=:72021 Content-Type: application/octet-stream; name="2.4.22-vm-writeback-inode.patch" Content-Transfer-Encoding: base64 Content-Description: 2.4.22-vm-writeback-inode.patch Content-Disposition: attachment; filename="2.4.22-vm-writeback-inode.patch" LS0tIHZtc2Nhbi5jLn4xfgkyMDAyLTExLTI4IDE4OjUzOjE1LjAwMDAwMDAw MCAtMDUwMAorKysgdm1zY2FuLmMJMjAwMy0wOC0yOCAxOTowOTo0OC4wMDAw MDAwMDAgLTA0MDAKQEAgLTIzLDYgKzIzLDExIEBACiAjaW5jbHVkZSA8bGlu dXgvaW5pdC5oPgogI2luY2x1ZGUgPGxpbnV4L2hpZ2htZW0uaD4KICNpbmNs dWRlIDxsaW51eC9maWxlLmg+CisjaW5jbHVkZSA8bGludXgvZnMuaD4KKyNp bmNsdWRlIDxsaW51eC9kY2FjaGUuaD4KKyNpZmRlZiBDT05GSUdfUVVPVEEK KyNpbmNsdWRlIDxsaW51eC9xdW90YS5oPgorI2VuZGlmCiAKICNpbmNsdWRl IDxhc20vcGdhbGxvYy5oPgogCkBAIC0zMzQsMTIgKzMzOSw1MiBAQAogCXJl dHVybiAwOwogfQogCisvKgorICogV2FpdCBmb3IgcGFnZXMgYmVpbmcgbGF1 bmRlcmVkIGFuZCBtb3ZlIHRoZW0KKyAqIHRvIHRhaWwgb2YgaW5hY3RpdmUg bGlzdCBpZiB0aGV5IGFyZSBzdGlsbCBmcmVlYWJsZS4KKyAqLworc3RhdGlj IHZvaWQgcHJvY2Vzc19sYXVuZHJ5KHN0cnVjdCBwYWdlICoqbGF1bmRyeSwg aW50IG5yX3BhZ2VzKQoreworCWludCBpOworCXN0cnVjdCBwYWdlICpwYWdl OworCisJZm9yIChpID0gbnJfcGFnZXMgLSAxOyBpID49IDA7IGktLSkgewor CQlwYWdlID0gbGF1bmRyeVtpXTsKKwkJc3Bpbl9sb2NrKCZwYWdlbWFwX2xy dV9sb2NrKTsKKworCQlpZiAoIVBhZ2VMUlUocGFnZSkgfHwgUGFnZUFjdGl2 ZShwYWdlKSkKKwkJCWdvdG8gbmV4dF9wYWdlOworCisJCWlmICh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spOwogI2lmZGVmIENPTkZJR19R VU9UQQotCXNocmlua19kcWNhY2hlX21lbW9yeShERUZfUFJJT1JJVFksIGdm cF9tYXNrKTsKKwkJc2hyaW5rX2RxY2FjaGVfbWVtb3J5KHByaW9yaXR5LCBn ZnBfbWFzayk7CiAjZW5kaWYKKwl9CiAKIAlyZXR1cm4gbnJfcGFnZXM7CiB9 Cg== --0-827563270-1062169271=:72021-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/