Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755561AbcKYQSs (ORCPT ); Fri, 25 Nov 2016 11:18:48 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:61336 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755074AbcKYQSl (ORCPT ); Fri, 25 Nov 2016 11:18:41 -0500 From: Arnd Bergmann To: Vitaly Wool Cc: Joe Perches , Andrew Morton , Dan Streetman , zhong jiang , Linux-MM , LKML Subject: Re: [PATCH] z3fold: use %z modifier for format string Date: Fri, 25 Nov 2016 17:11:49 +0100 Message-ID: <4155555.0I0VNuaa72@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: <20161124163158.3939337-1-arnd@arndb.de> <3177176.drX8hSSUx4@wuerfel> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:v3NKqvEc6w22aO3fVJZp6meYbfP42EftVJCiH1x4yhTsI8e+kb5 PDX1fXocWs1/Fqcd6aXuiFthO8yvKSWMfArNwfl7RA4ZLNylmcKUjdUV3nNnZNsaCdNpsdz QEmYb/+plFTfOyiIq+9tjSkxUe+kXzvTm6APtN569CRFDrPHpo8C0IdpBLt86v+Ea5o30HT AJDa47J4vhYOPEncFmegg== X-UI-Out-Filterresults: notjunk:1;V01:K0:U/6NPMydP4M=:Vie6yrQm7AWfZNpx86qS32 8pwzu/ReGlsORZOqYTb4q7AKaD2prVEk0Qrq4MgmebMO+uwsXB8Fw0hQYwEkmgGiiVDCAtfh3 WeEd8JwgqRhfPEBfr2Z9hlhiO0BW2CMuyVuWKp62cwKrWNl17FJFIWqmyZX6P39vgurJCoXXc DS0I4hCBNX6xu2wVLm5WIt1uk/3puf2jrfyACfI/p8gtAUnMp+uSCIFRJ0P1yzqHqWNba7h4u BAacesyPNkXTK9zHCnpD5pX8wBZBAQPC+OIBboIe2Z+dGEgdx9Tc/D+nQgoRGank4UZ3/+Yfo 70/dllEfKW0ZRxz/d/atlsQsQTk9mrGBk3ijcpwQGlKuYDFveuJhJ6qi10Oelgh9fjblhFSDG k84AXdtUEAGl6bWUpmwux7LhlP1A4Mc8X2lyCWeECDVRFG9KEpCjd+U3J2zJrSw7VdzSEeXdi Lf2LBFSowx4AFA4InkulXhtX3AtPq9ZUnC3ZV/aYxUOXDJITrUjbfF7XXsJjManYJjux+Pxin omfqfoRVFYKDq8pO2KhQcCNjOCALTFIpIV0aDR5S7ocY7ScYiEJeML61Ixs/4DG1AQvY0v0hk tkGVxO/0TYNcyV9C6o9Khbk5PEZ7ILpUkxzbJyMTanIvP6tzzqda6c7T7g8ogiSkOfrqALHwo cO4dVJQf7oxe7dieKMmPm0khc/2mOOltmT4jPr3VZvta84H9d1AWHXSTTskI8Y4Iu6sl6z4Rk tkbJ63q4o4bsRPXZ Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2899 Lines: 60 On Friday, November 25, 2016 4:51:03 PM CET Vitaly Wool wrote: > On Fri, Nov 25, 2016 at 9:41 AM, Arnd Bergmann wrote: > > On Friday, November 25, 2016 8:38:25 AM CET Vitaly Wool wrote: > >> >> diff --git a/mm/z3fold.c b/mm/z3fold.c > >> >> index e282ba073e77..66ac7a7dc934 100644 > >> >> --- a/mm/z3fold.c > >> >> +++ b/mm/z3fold.c > >> >> @@ -884,7 +884,7 @@ static int __init init_z3fold(void) > >> >> { > >> >> /* Fail the initialization if z3fold header won't fit in one chunk */ > >> >> if (sizeof(struct z3fold_header) > ZHDR_SIZE_ALIGNED) { > >> >> - pr_err("z3fold: z3fold_header size (%d) is bigger than " > >> >> + pr_err("z3fold: z3fold_header size (%zd) is bigger than " > >> >> "the chunk size (%d), can't proceed\n", > >> >> sizeof(struct z3fold_header) , ZHDR_SIZE_ALIGNED); > >> >> return -E2BIG; > >> > > >> > The embedded "z3fold: " prefix here should be removed > >> > as there's a pr_fmt that also adds it. > >> > > >> > The test looks like it should be a BUILD_BUG_ON rather > >> > than any runtime test too. > >> > >> It used to be BUILD_BUG_ON but we deliberately changed that because > >> sizeof(spinlock_t) gets bloated in debug builds, so it just won't > >> build with default CHUNK_SIZE. > > > > Could this be improved by making the CHUNK_SIZE bigger depending on > > the debug options? > > I don't see how silently enforcing a suboptimal configuration is > better than failing the initialization (so that you can adjust > CHUNK_SIZE yourself). I can add something descriptive to > Documentation/vm/z3fold.txt for that matter. Failing at runtime when you know it's broken at compile-time seems wrong, too. If you can't use z3fold with spinlock debugging, you may as well hide the option in Kconfig based on the other ones. Printing a runtime warning for the suboptimal configuration but making it work anyway is probably better than just failing. > > Alternatively, how about using a bit_spin_lock instead of raw_spin_lock? > > That would guarantee a fixed size for the lock and make z3fold_header > > always 24 bytes (on 32-bit architectures) or 40 bytes > > (on 64-bit architectures). You could even play some tricks with the > > first_num field to make it fit in the same word as the lock and make the > > structure fit into 32 bytes if you care about that. > > That is interesting. Actually I can have that bit in page->private and > then I don't need to handle headless pages in a special way, that > sounds appealing. However, there is a warning about bit_spin_lock > performance penalty. Do you know how big it is? No idea, sorry. On x86, test_and_set_bit() seems to be only one instruction to test/set the bit, followed by a conditional branch, compared to a cmpxchg() for the raw_spin_lock(), so the fast path seems pretty much the same. Arnd