From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F80EC433DF for ; Sat, 4 Jul 2020 02:32:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CA5242075D for ; Sat, 4 Jul 2020 02:32:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="rlCPDcfN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA5242075D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 511208D0011; Fri, 3 Jul 2020 22:32:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C1278D0001; Fri, 3 Jul 2020 22:32:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D77A8D0011; Fri, 3 Jul 2020 22:32:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0123.hostedemail.com [216.40.44.123]) by kanga.kvack.org (Postfix) with ESMTP id 28D3F8D0001 for ; Fri, 3 Jul 2020 22:32:13 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BA25B181AC9CB for ; Sat, 4 Jul 2020 02:32:12 +0000 (UTC) X-FDA: 76998818904.17.map51_2e1435e26e96 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 8453C180D0181 for ; Sat, 4 Jul 2020 02:32:12 +0000 (UTC) X-HE-Tag: map51_2e1435e26e96 X-Filterd-Recvd-Size: 2833 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Sat, 4 Jul 2020 02:32:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Rj09CRnYdkbD4EyDAG5ETpS3tXE9Hubs/ufs7DPvCTQ=; b=rlCPDcfNapYnKhC72LoltR8ZGX uMYnR+QhJI7WE4Z5iQBxBNgYcPPYT/7CD6NR1NaY6VBAXxw8Pc5bofJw+99MEhuq1MbxIyCr4KTiN yhK0YRjFx5BxY51uw4qfplR2f2qa+v9UxjngsIkNBqz4efdNgJhZB2/eQPV51PYpHznrelKdQTauN MqEHFnLMm/kijp4OP6fv5PZ2qw5k7VAf0X8OoM/S/s1Gsyca+CKdTIC7SFf09/smuHV6OTq3YFbKj yD8yKbjK3CuW60dV/de0loxB/iVOHc8Un4fG7maKNzBl+jwD3KJKSPRKQIzCa64HOxnF7QW5FT6Ef Xl/GgKFg==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrXyC-0007Hy-B3; Sat, 04 Jul 2020 02:32:00 +0000 Date: Sat, 4 Jul 2020 03:32:00 +0100 From: Matthew Wilcox To: Long Li Cc: cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, linux-mm@kvack.org Subject: Re: [PATCH v5] mm, slab: Check GFP_SLAB_BUG_MASK before alloc_pages in kmalloc_order Message-ID: <20200704023200.GK25523@casper.infradead.org> References: <20200704022607.GA57530@lilong> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200704022607.GA57530@lilong> X-Rspamd-Queue-Id: 8453C180D0181 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Jul 04, 2020 at 02:26:07AM +0000, Long Li wrote: > kmalloc cannot allocate memory from HIGHMEM. Allocating large amounts > of memory currently bypasses the check and will simply leak the memory > when page_address() returns NULL. To fix this, factor the > GFP_SLAB_BUG_MASK check out of slab & slub, and call it from > kmalloc_order() as well. In order to make the code clear, the warning > message is put in one place. > > Reviewed-by: Matthew Wilcox (Oracle) > Reviewed-by: Pekka Enberg > Cc: Christoph Lameter > Cc: David Rientjes > Cc: Joonsoo Kim > Cc: Andrew Morton > Signed-off-by: Long Li > --- > > changes in v5: > -Change the check function name to kmalloc_fix_flags(), This name > may be more appropriate. > > changes in V4: > -Change the check function name to kmalloc_check_flags() > -Put the flags check into the kmalloc_check_flags() No. As I said: The point of not doing that was that this is unlikely(). With your change there is now a function call to check something that's (extremely) unlikely().