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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 839F6C433EF for ; Thu, 2 Dec 2021 17:00:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E37316B0072; Thu, 2 Dec 2021 12:00:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DBF9A6B0073; Thu, 2 Dec 2021 12:00:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C398A6B0074; Thu, 2 Dec 2021 12:00:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0002.hostedemail.com [216.40.44.2]) by kanga.kvack.org (Postfix) with ESMTP id ADF576B0072 for ; Thu, 2 Dec 2021 12:00:45 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 71BD9886D0 for ; Thu, 2 Dec 2021 17:00:35 +0000 (UTC) X-FDA: 78873468030.25.B57FD29 Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) by imf28.hostedemail.com (Postfix) with ESMTP id 9B90C90000BB for ; Thu, 2 Dec 2021 17:00:34 +0000 (UTC) Received: by mail-qv1-f48.google.com with SMTP id gu12so57811qvb.6 for ; Thu, 02 Dec 2021 09:00:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=kbxwA3sKQ3VoXVlinWMZnniVnpttzpOT0znWtoAppcQ=; b=QcPmHVO5lAA/QTFeN3tFY0aYSNlJe0K3oiAx+Do8XqwGbTOeaZtSfwWnO+/gzfT7R7 uqhLZ92dKDZzytkEgVKaJSUU3YHoT/vjRYObGqLVSyM7yIs62wSQ8Pvmunpqu7PeNzX5 7PUJIOCrp7762zd/givR04oHd5nL5dQky1K2AUx3NCuRJWJotwBeNM45SeLtqbIjm9Kq lTWRnirQSSdYOdKpmmoNqfL3WOJTga/kJEKCLj+KcjWYRkeZQ3aGyshIjyRq2dNE/FXu fcqAj0/VFA05P+uKMNosQv/o3TdsHpzaTlpLTy67NqBZotIDtHtqEi/azkwgmAtwPRub rSFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kbxwA3sKQ3VoXVlinWMZnniVnpttzpOT0znWtoAppcQ=; b=qrgzBZhCQMwOPgEsq0eZpLVVh3YmARm78sZp1DFnw0EsM7TO7+kwITpGdVF/jXgv+0 8uIhq+RqzmQbjV7psVmrZ7Y0UXPMHm0vYVIS7vQZRw/RVpaBK/MmWPI7ZDQs0IFHYwJA sCXKRFKl9+p/WxJvfIR2qe4R2MKuUun3jMb+Au+d33MN3lOZe8h8mbC7k9g3/9M/iG/O MzKV1qibLmm/yqB5LCM/qWv2QnDlDvpS/eRLLg5YX3h6COKB96lUueketcokUGRud69V B9ALwpgXTbGYS/xvPTAr7naDd6tLYS0UBSO4Q6EjfUx8VD+eDYC5sK1YkK2MnVHv/rf4 y4aw== X-Gm-Message-State: AOAM531WRogTcuaW0ILUiA/Eu/lpAu562/6nly4QsXKcumaDD+u/2s4A FAFOa4qNEwVJrxfc8Zuq2332UWHGirkSvw== X-Google-Smtp-Source: ABdhPJzO9oFxXAyQcrmDiRj9xkoyqtrbKrukesQ7GrY6BtK7F42G6UcjyCUO6WC60QJn/7zM+JX/Vg== X-Received: by 2002:a05:6214:1d03:: with SMTP id e3mr14469202qvd.61.1638464433983; Thu, 02 Dec 2021 09:00:33 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-113-129.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.129]) by smtp.gmail.com with ESMTPSA id bp38sm264091qkb.66.2021.12.02.09.00.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 09:00:33 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1mspRg-0071lx-DU; Thu, 02 Dec 2021 13:00:32 -0400 Date: Thu, 2 Dec 2021 13:00:32 -0400 From: Jason Gunthorpe To: Matthew Wilcox Cc: Leon Romanovsky , Andrew Morton , Bixuan Cui , linux-mm@kvack.org, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, w@1wt.eu, keescook@chromium.org Subject: Re: [PATCH -next] mm: delete oversized WARN_ON() in kvmalloc() calls Message-ID: <20211202170032.GN5112@ziepe.ca> References: <1638410784-48646-1-git-send-email-cuibixuan@linux.alibaba.com> <20211201192643.ecb0586e0d53bf8454c93669@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 9B90C90000BB Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=ziepe.ca header.s=google header.b=QcPmHVO5; dmarc=none; spf=pass (imf28.hostedemail.com: domain of jgg@ziepe.ca designates 209.85.219.48 as permitted sender) smtp.mailfrom=jgg@ziepe.ca X-Stat-Signature: gqtk5yxezm67ok4guoyc54kd9ya4po9j X-HE-Tag: 1638464434-556918 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 Thu, Dec 02, 2021 at 03:29:47PM +0000, Matthew Wilcox wrote: > On Thu, Dec 02, 2021 at 05:23:42PM +0200, Leon Romanovsky wrote: > > The problem is that this WARN_ON() is triggered by the users. > > ... or the problem is that you don't do a sanity check between the user > and the MM system. I mean, that's what this conversation is about -- > is it a bug to be asking for this much memory in the first place? > > > At least in the RDMA world, users can provide huge sizes and they expect > > to get plain -ENOMEM and not dump stack, because it happens indirectly > > to them. > > > > In our case, these two kvcalloc() generates WARN_ON(). > > > > umem_odp->pfn_list = kvcalloc( > > npfns, sizeof(*umem_odp->pfn_list), GFP_KERNEL); > > Does it really make sense for the user to specify 2^31 PFNs in a single > call? I mean, that's 8TB of memory. Should RDMA put its own limit > in here, or should it rely on kvmalloc returning -ENOMEM? I wrote this - I don't think RDMA should put a limit here. What limit would it use anyhow? I'm pretty sure database people are already using low TB's here. It is not absurd when you have DAX and the biggest user of ODP is with DAX. If anything we might get to a point in a few years where the 2^31 is too small and this has to be a better datastructure :\ Maybe an xarray and I should figure out how to use the multi-order stuff to optimize huge pages? I'd actually really like to get rid of it, just haven't figured out how. The only purpose is to call set_page_dirty() and in many cases the pfn should still be in the mm's page table. We also store another copy of the PFN in the NIC's mapping. Surely one of these two could do instead? Jason