Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964806AbdHYWvV (ORCPT ); Fri, 25 Aug 2017 18:51:21 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:34448 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964792AbdHYWvS (ORCPT ); Fri, 25 Aug 2017 18:51:18 -0400 MIME-Version: 1.0 In-Reply-To: References: <83f675ad385d67760da4b99cd95ee912ca7c0b44.1503677178.git.tim.c.chen@linux.intel.com> From: Linus Torvalds Date: Fri, 25 Aug 2017 15:51:17 -0700 X-Google-Sender-Auth: y4l14b49QzAHRvc1BDDJ1hy6lE0 Message-ID: Subject: Re: [PATCH 2/2 v2] sched/wait: Introduce lock breaker in wake_up_page_bit To: Tim Chen Cc: Mel Gorman , Peter Zijlstra , Ingo Molnar , Andi Kleen , Kan Liang , Andrew Morton , Johannes Weiner , Jan Kara , Christopher Lameter , "Eric W . Biederman" , Davidlohr Bueso , linux-mm , Linux Kernel Mailing List Content-Type: multipart/mixed; boundary="001a11c1691e72570105579bc813" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 43325 Lines: 604 --001a11c1691e72570105579bc813 Content-Type: text/plain; charset="UTF-8" On Fri, Aug 25, 2017 at 3:19 PM, Tim Chen wrote: > > Also I think patch 1 is still a good idea for a fail safe mechanism > in case there are other long wait list. Yeah, I don't hate patch #1. But that other patch is just nasty. > That said, I do think your suggested approach is cleaner. However, it > is a much more substantial change. Let me take a look and see if I > have any issues implementing it. Actually, I tried it myself. It was painful. But I actually have a TOTALLY UNTESTED set of two patches that implements the idea. And by "implements the idea" I mean "it kind of compiles, and it kind of looks like it might work". But by "kind of compiles" I mean that I didn't implement the nasty add_page_wait_queue() thing that the cachefiles interface wants. Honestly, I think the sanest way to do that is to just have a hashed wait queue *just* for cachefiles. And by "kind of looks like it might work" I really mean just that. It's entirely untested. It's more of a "let's take that description of mine and turn it into code". I really have not tested this AT ALL. And it's subtle enough that I suspect it really is majorly buggy. It uses the locking hash list code (hlist_bl_node) to keep the hash table fairly small and hide the lock in the hash table itself. And then it plays horrible games with linked lists. Yeah, that may have been a mistake, but I thought I should try to avoid the doubly linked lists in that "struct page_wait_struct" because it's allocated on the stack, and each list_head is 16 bytes on 64-bit architectures. But that "let's save 24 bytes in the structure" made it much nastier to remove entries, so it was probably a bad trade-off. But I'm attaching the two patches because I have no shame. If somebody is willing to look at my completely untested crap code. I *really* want to emphasize that "untested crap". This is meant to be example code of the *concept* rather than anything that actually works. So take it as that: example pseudo-code that happens to pass a compiler, but is meant as a RFD rather than actually working. The first patch just moves code around because I wanted to experiment with the new code in a new file. That first patch is probably fine. It shouldn't change any code, just move it. The second patch is the "broken patch to illustrate the idea". Linus --001a11c1691e72570105579bc813 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Split-page-bit-waiting-functions-into-their-own-file.patch" Content-Disposition: attachment; filename="0001-Split-page-bit-waiting-functions-into-their-own-file.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_j6sh0dn00 RnJvbSBiMGJlYzFkZThhN2RiYTY5YjIyM2RkMzBkZDJhNzM0NDAxZjMzNWFhIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBMaW51cyBUb3J2YWxkcyA8dG9ydmFsZHNAbGludXgtZm91bmRh dGlvbi5vcmc+CkRhdGU6IEZyaSwgMjUgQXVnIDIwMTcgMTM6MjU6NDMgLTA3MDAKU3ViamVjdDog W1BBVENIIDEvMl0gU3BsaXQgcGFnZSBiaXQgd2FpdGluZyBmdW5jdGlvbnMgaW50byB0aGVpciBv d24gZmlsZQoKSXQgdHVybnMgb3V0IHRoYXQgdGhlIHBhZ2UtYml0IHdhaXRpbmcgbG9naWMgaXMg dmVyeSBzcGVjaWFsIGluZGVlZCwgYW5kCndpbGwgZ2V0IGV2ZW4gbW9yZSBzby4gIFNwbGl0IGl0 IHVwIGlud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dlKHBhZ2Us IFBHX3dyaXRlYmFjayk7Cit9CitFWFBPUlRfU1lNQk9MKGVuZF9wYWdlX3dyaXRlYmFjayk7Ci0t IAoyLjE0LjAucmMxLjIuZzRjODI0N2VjMwoK --001a11c1691e72570105579bc813 Content-Type: text/x-patch; charset="US-ASCII"; name="0002-Re-implement-the-page-bit-wait-code.patch" Content-Disposition: attachment; filename="0002-Re-implement-the-page-bit-wait-code.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_j6sh0iq61 RnJvbSA4Y2Y5Mzc3Yzk4ZDc3YjJhMmRlMGRiYzQ1MWU4YWMyODM2ODRhNGUyIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBMaW51cyBUb3J2YWxkcyA8dG9ydmFsZHNAbGludXgtZm91bmRh dGlvbi5vcmc+CkRhdGU6IEZyaSwgMjUgQXVnIDIwMTcgMTU6NDU6NDMgLTA3MDAKU3ViamVjdDog W1BBVENIIDIvMl0gUmUtaW1wbGVtZW50IHRoZSBwYWdlIGJpdC13YWl0IGNvZGUKClRoZSBwYWdl IHdhaXQtcXVldWVzIGhhdmUgc29tZSBob3JyaWJsZSBzY2FsaW5nIGlzc3VlcywgYW5kIHRoZXkg c2VlbSB0bwpiZSBoYXJkIHRvIGZpeC4gIEFuZCB0aGUgd2F5IHRoZXkgdXNlIHRoZSByZWd1bGFy IHdhaXQtcXVldWVzIG1hZGUgdGhhdApyZWFsbHkgYmFkLCB3aXRoIGludGVycnVwdHMgZGlzYWJs ZWQgZm9yIGxvbmcgdGltZXMgZXRjLgoKVGhpcyB0cmllcyB0byByZS1pbXBsZW1lbnQgdGhlbSB3 aXRoIGEgdG90YWxseSBkaWZmZXJlbnQgbW9kZWwuICBJdCdzCmtub3duIGJyb2tlbiwgYW5kIHRo ZSBhZGRfcGFnZV93YWl0X3F1ZXVlKCkgdGhpbmcgdGhhdCB0aGUgY2FjaGVmaWxlcwpjb2RlIHdh bnRzIHRvIHVzZSBpcyBub3Qga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