Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2950473imm; Thu, 24 May 2018 19:44:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpoDeWOi6lkZDTpBqsRigdO6YITN9Y1EdVfpCCFsGNmh28t0hM64ccI/zpFFnqIoFUDHe0W X-Received: by 2002:a62:ecdc:: with SMTP id e89-v6mr592161pfm.33.1527216259665; Thu, 24 May 2018 19:44:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527216259; cv=none; d=google.com; s=arc-20160816; b=E2PwoBQ0HhmLjWL/rrPMt9WmLF7jNjNT32kuSsnC8tzzSk+H7SjlXo22WBx4HJqq4T YWd0P8jEwJnxqfRKr3xTfxTy3VMX0YhWglrTmG/xG8TXTgBd6cDIvxc/pz+APVP4BFhk E6aM10CxP6PF27I+lV2KfMskdziQuuhLm5Im15WGXhPZ0e8HxyV5KTr5U8IZA2sNscPz TU/lEfjitvL835RVvXnA/qOh4YTaRuPHE82ix2kF/kW2r8fnJHkGDRKK9f7/QE4ENuUj 5lgWhFRn85thjQ4JqVLiEKQHlUryHDWOK/h7mWh1s1sy9sDkiJ6wszoXkgOWm/6dEhvs SuIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=Vpw3+/4jG5zA/xgRzb45c3uKbDFbBNPq4eZ9SvMjm5Q=; b=bACash1x0PNj7yHAxh/S9gXjyBSSOJmCpXYSDKE5q8FTbK6JIpOSPou5EYCBcSq7ux +c4sn87+Y+/beinqsD3Nq0+APls4k04OQZxrd2JhIQ+rW4H8O+qAjTd/Weg7fOICPvCb u9xNhT19O0y6COny7Hc3Qqnre5dHNBGNbmfG6ARAr545OlcwBKYysI9IyuecdAPS5hlZ HErPmsOXKUnNivwNWh3/0tSRHC9HrJtWgyvw5jU3tb5u2CK9iYnc9QCauCysowjur2GD KpHOu/Zqn7Q3RCGOVU2Ax0M1pCRbo+2BjWCeL/n3FBFTpVDbt8DRQB9aV0TLJ7HeMT+B 3bmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=BSD4NBxL; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g2-v6si21392504pfh.346.2018.05.24.19.44.05; Thu, 24 May 2018 19:44:19 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=BSD4NBxL; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969643AbeEXVhx (ORCPT + 99 others); Thu, 24 May 2018 17:37:53 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:37262 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969582AbeEXVhs (ORCPT ); Thu, 24 May 2018 17:37:48 -0400 Received: by mail-it0-f66.google.com with SMTP id 70-v6so4342598ity.2; Thu, 24 May 2018 14:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Vpw3+/4jG5zA/xgRzb45c3uKbDFbBNPq4eZ9SvMjm5Q=; b=BSD4NBxLGS9RUYh3r5KXNtXtMy94JcEC0+ytDJzuQML1I4I8y8uIZLtt1vWAs5iXap 3T2UtYsCYUjDp4h03O4yjDHanLJQVrk1hhR1McOToJqkQNSY4+eJC7jpcbMeuyAEBz7a IDTBmEWIvxQmEGFqaiFfW4ZXf7n9D41SQhepM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Vpw3+/4jG5zA/xgRzb45c3uKbDFbBNPq4eZ9SvMjm5Q=; b=l7CPry12hzaoBKm3+S/dIzjMvQ0VAgN/J5lA098S+ouYWIWXLB5hwQ3B5ajG/NOa3l Yom19YvG5LJvX3ZfrNYgd46B53YeFPjRz7kghYU0CGqI+ZYv3pVIOesNfkiIFN+DO9uo WP0ZAfI4zZOYbdCBF/uTtVyRKTe1+9NbBtUMcrsLtHp3qQMOaoO5uQN+9DNLGtzYgQIg mMSKn0PXV1IAYV/2NUyVaWaN/YXmRLYbP6llgMn1+ju2q5oUVVB/XpXoqgqYicEXGhRS 3ru/vdMoS5aq/71WBkSetrn/3Tzi5pfFoe59krEeBjOVkZhVtywZEkbNTeLFezDX915O 4Vzg== X-Gm-Message-State: ALKqPwefQHmBfCTtn2xPAWpvjEHnQJeaokIUH251Mw/j/u1xtuT0bXyI bbJcvASnLpPm6cF/2rYAuaErQvkHERZ/9rZMG3g= X-Received: by 2002:a24:7554:: with SMTP id y81-v6mr625499itc.1.1527197867614; Thu, 24 May 2018 14:37:47 -0700 (PDT) MIME-Version: 1.0 References: <20180524211135.27760-1-dave@stgolabs.net> <20180524211135.27760-4-dave@stgolabs.net> In-Reply-To: <20180524211135.27760-4-dave@stgolabs.net> From: Linus Torvalds Date: Thu, 24 May 2018 14:37:36 -0700 Message-ID: Subject: Re: [PATCH 3/6] lib/bucket_locks: use kvmalloc_array() To: Davidlohr Bueso Cc: Andrew Morton , Thomas Graf , Herbert Xu , Manfred Spraul , guillaume.knispel@supersonicimagine.com, Linux API , Linux Kernel Mailing List , Davidlohr Bueso Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? 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? Linus