From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751457AbbLVBXN (ORCPT ); Mon, 21 Dec 2015 20:23:13 -0500 Received: from mail-ig0-f181.google.com ([209.85.213.181]:35603 "EHLO mail-ig0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751237AbbLVBXM (ORCPT ); Mon, 21 Dec 2015 20:23:12 -0500 MIME-Version: 1.0 In-Reply-To: References: <20151221234615.GW20997@ZenIV.linux.org.uk> <20151222010403.GX20997@ZenIV.linux.org.uk> Date: Mon, 21 Dec 2015 17:23:11 -0800 X-Google-Sender-Auth: DXdzvjD2ObV2ngn3vEx8eZp9JDk Message-ID: Subject: Re: [RFC] free_pages stuff From: Linus Torvalds To: Al Viro Cc: Linux Kernel Mailing List Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Grr. Resending because the stupid android gmail app still can't do text emails ] On Dec 21, 2015 17:04, "Al Viro" wrote: > > > And quite frankly, even the "new name" is likely a bad idea. If you > > want to allocate a page, and get a pointer, just use "kmalloc()". > > Boom, done! > > Erm... You've just described the absolute majority of callers. Really. That wasn't my point. I totally believe that most of the legacy users actually wanted a pointer. But that doesn't mean that we should just convert a legacy interface. We should either just create a new interface and leave old users alone, or if we care about that code and really want to remove the cast, maybe it should just use kmalloc() instead. Long ago, allocating a page using kmalloc() was a bad idea, because there was overhead for it in the allocation and the code. These days, kmalloc() not only doesn't have the allocation overhead, but may actually scale better too, thanks to percpu caches etc. So my point here is that not only is it wrong to change the calling convention for a legacy function (and it really probably doesn't get much more legacy than get_free_page - I think it's been around forever), but even the "let's make up a new name" conversion may be wrong, because it's entirely possible that the code in question should just be using kmalloc(). So I don't think an automatic conversion is a good idea. I suspect that old code that somebody isn't actively working on should just be left alone, and code that *is* actively worked on should maybe consider kmalloc(). And if the code really explicitly wants a page (or set of aligned pages) for some vm reason, I suspect having the cast there isn't a bad thing. It's clearly not just a random pointer allocation if the bit pattern of the pointer matters. And yes, most of the people who used to want "unsigned long" have long since been converted to take "struct page *" instead, since things like the VM wants highmem pages etc. There's a reason why the historical interface returns "unsigned long": it _used_ to be the right thing for a lot of code. The fact that there now are more casts than not are about changing use patterns, but I don't think that means that we should change the calling convention that has a historical reason for it. Linus