Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3467323imm; Tue, 29 May 2018 07:45:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo/R5y0z9clTHbeIX2KuepRr43vSLFCQq4QEmIiaWXwSIKzRSAYXnZom3TqatzmYpHIrtFT X-Received: by 2002:a62:fb14:: with SMTP id x20-v6mr17701780pfm.48.1527605136720; Tue, 29 May 2018 07:45:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527605136; cv=none; d=google.com; s=arc-20160816; b=yMisGhz+6w4CPnCfzR0fi1H8xZVIEgKQGxldTtCa9NvxheUwXt9bBZHy/UI7q3ej8T vbdW5TOi0rduICE3/T80S5SJm3mTRqa7Vz75RfexN3yWRza1x+ULcQ8XoYQCfgcIY1eN pPYINDLDwIvJ2fGy1tYtMRhgVOHb9lDsLwD/6iDjkbzPXBmngHchplhy/3lE2pCRydQp TFv1pPmSGfCJpBC7Xk6D0FKD8/4rEeIpgNFfcBAqjljB9Ons20DpBn8xL959bex5fgwq 9OxSmRXsdncBJAQcrvF6wmcCvFUyXRs8RivQFT2w8nxCydzb2Z+6lK0j1bn4N07gcyZA RRUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=czUtXadmyq45FZ63ln/Xj3ezyAa9BkTswOkuprmJRgI=; b=ivhDd9l7NgWQUxJMUsnxec/amL6EKUSgc9oOAKze0Q+Wffm7mAswI3L5Hl0Km7bWbF FvtfRTa6A/Dx5ULFQ2T48tuHt1TEnyv+QlwtHvhRt3fUDs/aeNFifsyyAscXPK/RvSLR b1gCPZA0IoBeF7WyYs3PBgjv/Cp+V1SMxDEdiZU/Gb4gvsztwL10Qh1MvmLxpIv39/Ei SdZWIFiWvIJgnCIjSSlX/hGrjB9ipcdpy2GkDNU9ZC6QS8hKXSJVP1W3PAy3WVczIUTv ZkCHi+uU0pJZQvEfv7rx87389DqaPtqYHpEa2q7UnV49NxfFy8ef9siJuzbMvfrkgLQ9 aITA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a62-v6si10522199pge.492.2018.05.29.07.45.22; Tue, 29 May 2018 07:45:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935515AbeE2OnY (ORCPT + 99 others); Tue, 29 May 2018 10:43:24 -0400 Received: from mx2.suse.de ([195.135.220.15]:54156 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935077AbeE2OnU (ORCPT ); Tue, 29 May 2018 10:43:20 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6256DAF7B; Tue, 29 May 2018 14:43:19 +0000 (UTC) Date: Tue, 29 May 2018 16:43:17 +0200 From: Michal Hocko To: Linus Torvalds Cc: Davidlohr Bueso , Andrew Morton , Thomas Graf , Herbert Xu , Manfred Spraul , guillaume.knispel@supersonicimagine.com, Linux API , Linux Kernel Mailing List , Davidlohr Bueso Subject: Re: [PATCH 3/6] lib/bucket_locks: use kvmalloc_array() Message-ID: <20180529144317.GA20910@dhcp22.suse.cz> References: <20180524211135.27760-1-dave@stgolabs.net> <20180524211135.27760-4-dave@stgolabs.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 24-05-18 14:37:36, Linus Torvalds wrote: > On Thu, May 24, 2018 at 2:28 PM Davidlohr Bueso wrote: > > > if (gfpflags_allow_blocking(gfp)) > > - tlocks = kvmalloc(size * sizeof(spinlock_t), gfp); > > + tlocks = kvmalloc_array(size, sizeof(spinlock_t), > gfp); > > else > > tlocks = kmalloc_array(size, sizeof(spinlock_t), > gfp); > > Side note: how about we just move that "gfpflags_allow_blocking()" into > kvmalloc() instead, and make kvmalloc() generally usable? > > Now we have that really odd situation where kvmalloc() takes gfp flags, but > to quote the comment: > > * Any use of gfp flags outside of GFP_KERNEL should be consulted with mm > people. > > and the code: > > /* > * vmalloc uses GFP_KERNEL for some internal allocations (e.g page > tables) > * so the given set of flags has to be compatible. > */ > WARN_ON_ONCE((flags & GFP_KERNEL) != GFP_KERNEL); > > which isn't really all that helpful. Do mm people really want to be > consulted about random uses? The purpose was to have a clean usage base after the conversion. If we are growing a non-trivial use base which wants to use GFP_NOWAIT semantic then sure we can make kvmalloc never fallback to vmallock. But see below... > Maybe we could just make the rule for kvmalloc() be to only fall back on > vmalloc for allocations that are > > - larger than page size > > - blocking and allow GFP_KERNEL (so basically that WARN_ON_ONCE() logic in > kvmalloc_node). > > Hmm? Isn't that what everybody really *wants* kvmalloc() and friends to do? ... Well, there are users who would like to use kvmalloc for GFP_NOFS/GFP_NOIO context. Do we want them to fail more likely for larger order rather than have them fixed (to either drop the NOFS because it just has been blindly copied from a different code without too much thinking or use the scope NOFS/NOIO API)? A warn_on tends to be rather harsh but effective way to push maintainers fix their broken code... -- Michal Hocko SUSE Labs