Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3994148pxb; Tue, 25 Jan 2022 00:56:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwD2sz79sGblrh245sdIcv0u25qsh/rmxe4S0H6lO5SZENVPMMn4zrSST6K4DU1nAQUPOmE X-Received: by 2002:a17:90b:714:: with SMTP id s20mr2473495pjz.31.1643101017012; Tue, 25 Jan 2022 00:56:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643101017; cv=none; d=google.com; s=arc-20160816; b=JK4SmLFVu1dfwjmbXvMLh2tpONJS75sEVD4Q/mL6duCrKRex/GSUpedv89Id+/wgE7 zWF+tJr9lm5v9kfaVrzFFu4RQjkWrVhsT7Nik842bNyX/KQGUv87Sn8F5rj6cmgsUNAm Ok4qCT1Tr2RujjA+OqlGMxBdSj9zzKtWx/wZ0qez5NwNWsx47/lhYeSHKZSIyTi2H+Hx G+OZ32RqXE11JMmYrw1q0qsEFxQytkwHiEp99+uZ16mgoT9Rt5iyqKM6IHqj+P6Q44Iq ZgAMPWYx4lIpRn0ZsSLvEK7jUusqOREf7hyEg5CkSjTCo8qD4AfURkY1leoyPPUOiMGT gBkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=dRYUZ3M7rYppnI+hr0K9I96s0E7Snr+RM+8KvNOCFtU=; b=R2Z7gnzbGzDrS+NUcuFQ06KIQ7TnEoPZE5hhnXuL2aOI7BBBmxenbJCPob97GOIajq wNlMyhE790btCZ5lzD8WNwmafrUXY3hnRjE2dB/zaXGjMmATLbWtjLDS8raKOTPSvlQF felDWJ7HynUs9kox64HSFDgt4YDZPcgAaruRLBDC3yJL8aT8N6NnWljzXhC2zrEPUxcH htu51q9jNWFzd6W/JgXyo2dC7FKD+lf/KFvo16XcLjZVuBpjnK0WTLx3ghLBg2etor32 yd+bHAUaLxj8JmyHsBDaF2QUwZtW5Jts4OOabkwow72stTK/qqdeSk2ifbFb072ydeFP 9rhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VD8oeGdq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q7si716460pfu.195.2022.01.25.00.56.44; Tue, 25 Jan 2022 00:56:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VD8oeGdq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S254945AbiAYExi (ORCPT + 99 others); Mon, 24 Jan 2022 23:53:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S3412751AbiAYEmD (ORCPT ); Mon, 24 Jan 2022 23:42:03 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3CC0C061756; Mon, 24 Jan 2022 19:21:56 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id p125so17203776pga.2; Mon, 24 Jan 2022 19:21:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dRYUZ3M7rYppnI+hr0K9I96s0E7Snr+RM+8KvNOCFtU=; b=VD8oeGdqW09JSIqWe22HlKYenwRDp2U8WB+CnjY9QLzalkATlxubrBmgjYYpfW6yCY 1n07L6NKNOdq6J5J+VoxM0dHKSLcYBwSHN1OUYe2tsN889Jw9me66zKLHFVus7BiiWUw RLkkqAtHIvkBY32Zec94woTaIa0mYUIvOEzYAQzbiU2k4Q4nJwMcuLPd3DDGGEMxpdRR dIeGhMe0j2TWZUIW20y/3h0vUAStXPE1oj0nGC5Klr7KclyeFrKIZKGaoLDP+jx4ZAuQ IF9XsGGcHnzSbDikDNG3Lq27ObcBgORcGhKZfLNzpKtXqKo6rbyACvIgwmpFVyAmvJrA N+4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dRYUZ3M7rYppnI+hr0K9I96s0E7Snr+RM+8KvNOCFtU=; b=7TtkTlHWL/GsEi1zsoQyXJikadWnbkvlZb9A4CSyc2CilJ+X34/rEjZ02W/Ec79o1V TkHGX9w9WmTRoASan8r9h6D19IMvYlZ1GVTW2wht56uvySeh7Z3Gp6ZEDpr0AZhdTZs/ Rxpy7bSOW3y4WQW8jXUMUuHqPJHtlTNnvgqjdUqPTS2+Nm4iwBzCuKwNH3BM/8XIyzJc +YeccKAooOtLpDYQC8c/DxOT63lajz7zsgRRvkp+AVYuegg2OLFFvA5PHHI9817QBlti 5NI8tIgs4xu7OGGFhq90ZcqjAc1Ajza+x96/OK1jTFWejNyhpSHB1eug5YVFkO85ojbV DxaQ== X-Gm-Message-State: AOAM5304+GLtwtkmSaNWCHTuRKtB9mTrarJsLmEnkrA+0zg0VLnpsz8u XYeVADl1v+O2UjX6+BUCTQffnIZKqPLmBIVZ0cQdfBfGkEE= X-Received: by 2002:aa7:88d4:0:b0:4ca:a670:d05f with SMTP id k20-20020aa788d4000000b004caa670d05fmr2460464pff.38.1643080915561; Mon, 24 Jan 2022 19:21:55 -0800 (PST) MIME-Version: 1.0 References: <20220104171058.22580-1-avagin@gmail.com> In-Reply-To: <20220104171058.22580-1-avagin@gmail.com> From: Andrei Vagin Date: Mon, 24 Jan 2022 19:21:44 -0800 Message-ID: Subject: Re: [PATCH] fs/pipe: use kvcalloc to allocate a pipe_buffer array To: LKML , Andrew Morton , Alexander Viro , Christian Brauner Cc: linux-fsdevel , Dmitry Safonov <0x7f454c46@gmail.com> Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 4, 2022 at 9:11 AM Andrei Vagin wrote: > > Right now, kcalloc is used to allocate a pipe_buffer array. The size of > the pipe_buffer struct is 40 bytes. kcalloc allows allocating reliably > chunks with sizes less or equal to PAGE_ALLOC_COSTLY_ORDER (3). It means > that the maximum pipe size is 3.2MB in this case. > > In CRIU, we use pipes to dump processes memory. CRIU freezes a target > process, injects a parasite code into it and then this code splices > memory into pipes. If a maximum pipe size is small, we need to > do many iterations or create many pipes. > > kvcalloc attempt to allocate physically contiguous memory, but upon > failure, fall back to non-contiguous (vmalloc) allocation and so it > isn't limited by PAGE_ALLOC_COSTLY_ORDER. > > The maximum pipe size for non-root users is limited by > the /proc/sys/fs/pipe-max-size sysctl that is 1MB by default, so only > the root user will be able to trigger vmalloc allocations. > > Cc: Dmitry Safonov <0x7f454c46@gmail.com> > Signed-off-by: Andrei Vagin Alexander and Andrew, Do you have any objections? Could you merge this patch? Dmitry's comments have been addressed in the separate patch: https://lkml.org/lkml/2022/1/6/463 BTW: I found that fuse already uses kvmalloc to allocate pipe buffers (e. g. fuse_dev_splice_read). Thanks, Andrei