Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4830643ioo; Tue, 31 May 2022 12:41:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxd8tZOFuUqbHTSZldYSkEGrckh59/8EFFtCbWTJYXsXMQHjnycVXjE01dQS5d1/e4CH+fN X-Received: by 2002:a63:e603:0:b0:3fb:c191:9b65 with SMTP id g3-20020a63e603000000b003fbc1919b65mr17117905pgh.12.1654026089338; Tue, 31 May 2022 12:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654026089; cv=none; d=google.com; s=arc-20160816; b=keYdUzAIONszKzNIPyObNrDTEoU1Yj0WqDQV54mwxYmkMWEn8nN0NB6qHCdcJWRwBx nxc4IjhXwk1ERz72mf3vqvTrXjCAr/uotlpIXaYUchWjMi3Rd7uz+Jo/Bw0QYyikZsSW 5s6IbTxIZAOm7hTt/1XlrNMsCTkiKiJOJNfuUlHc97iYD46u0ZTmYi6pdF7Ro/KSNPW+ 9lri+tsjhZNxooXCdfSto9M8aqM5TySujBtnW8LMcuKyWvWoVxt3k9x9ij+lKNc93OV6 SeTHuETwDhGcAqdppxUHhFaZNRxz1gf9SYBYfyf1o5kfIyMwbGchmFau1fgNvmHQpQ1a TUcA== 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=DgNqW4//ddECki3dc1mKGiHL7tQBiKwjHn92jkr+JC8=; b=clPGDc/9BVSEH0mASEx0b6HpdeWewxpE9tY6yJDSowi/DWIa7hv9sHEBhLEQ5cNZZt s6lpQR5gA67NEDspQ2lIM8RUvUyoXC5VpZAZlWZ95mhk/gJMXN0KMFf4CUaFHGslrzS4 nKxZB4zl6s4NV7xziStEuyPDoGY1/lGWsIZjWNBSYTZJ9NNxChgHqHKfQeRFsLPnfWrs J5Tg8Sbrx06HkI56fXlfzU60k17m1Kk0Dvv2I2FU8uGEGPzNtf/WyuAGAH9NibW9oHKE CAbr8rQMYcBy+gpw0Y6fEmA/LdB1l4IOERNt/xIfxIPoDYKCFdL0Ea667XGQWlTZnnUN I6mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d1WWUT5C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ml23-20020a17090b361700b001e2f19b2126si3657716pjb.13.2022.05.31.12.41.17; Tue, 31 May 2022 12:41:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d1WWUT5C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1347054AbiEaS3P (ORCPT + 99 others); Tue, 31 May 2022 14:29:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347047AbiEaS3N (ORCPT ); Tue, 31 May 2022 14:29:13 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0597532FF; Tue, 31 May 2022 11:29:12 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id t5so18710789edc.2; Tue, 31 May 2022 11:29:12 -0700 (PDT) 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=DgNqW4//ddECki3dc1mKGiHL7tQBiKwjHn92jkr+JC8=; b=d1WWUT5CdthQk2XN9McJR10DNsns2iAqPovkQCkpfZLnlhdh7wC2dFlNszNMcqD3Ij YYfgROZFScvyXQKZjxYps4O1VcDZYwwtiFedp0WlGwmE05VLMT2osLDfo/l/4Ulky0Dt VtDPTstUcwrukbKqFlF3YyfyIPyFul6ylsK+B8yoFnrxRq8hBq37p0xr+dpp18g65qZL V8yFX6N1IAeYjC0i4Gf/WokNIglZiTghMk4Uy3cfy1nfOGWHwxFLIGnKP2qeVbNtmZxO K5JexoUXnO4BW7VDoBp3/2DR/lOlBhN43cIaVqRslZslUnmQOlLA4CM+9qzjK9hFbu79 SzMw== 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=DgNqW4//ddECki3dc1mKGiHL7tQBiKwjHn92jkr+JC8=; b=QjX2v4Mv44PcnLvenJiWfGuEf1knuEeNSTBdSP70LwQLl2roa4kN+zwaMZkN8amixu 3oJLf1tj6Pt/k8c7crzPxoPXN1hRbOp/VRzN0+n9F0CEGjZ99wfOLioTvv8q+kHL+TqY x5LJVtGeSSeEb1O1DZnTWmj4WXLQCfHsdiWsFFf8Li5E4wP9F7RAAZdCdQoRE8WLMg/z Q7Vm5vHmx8S/wbq9ARvvzZAogjyL+TvFjru8IHDzSmh552S9FDULlcuhP9/0FPhrvAIY jUvTLbaSzDwtEYyDLVdKwc8ByLEPSz10LR2UlW4FSy7+iLSgyBWHUe3ea3eneMmHLj5X 8E6w== X-Gm-Message-State: AOAM5306ry3lD1q/9FTvfYTEdXkpKzNrqIOpsIAf7+Q4R5dRYU6h5qkw JtXLd/QeyMVXxff15kWTJO5j4SN2mjUW4hxzVoOxxJTc67Q= X-Received: by 2002:a05:6402:3299:b0:42d:d630:7ce1 with SMTP id f25-20020a056402329900b0042dd6307ce1mr9998252eda.136.1654021751120; Tue, 31 May 2022 11:29:11 -0700 (PDT) MIME-Version: 1.0 References: <20220531081412.22db88cc@kernel.org> <1654011382-2453-1-git-send-email-chen45464546@163.com> <20220531084704.480133fa@kernel.org> In-Reply-To: <20220531084704.480133fa@kernel.org> From: Alexander Duyck Date: Tue, 31 May 2022 11:28:59 -0700 Message-ID: Subject: Re: [PATCH v2] mm: page_frag: Warn_on when frag_alloc size is bigger than PAGE_SIZE To: Jakub Kicinski Cc: Chen Lin , Andrew Morton , linux-mm , LKML , Netdev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 31, 2022 at 8:47 AM Jakub Kicinski wrote: > > On Tue, 31 May 2022 23:36:22 +0800 Chen Lin wrote: > > At 2022-05-31 22:14:12, "Jakub Kicinski" wrote: > > >On Tue, 31 May 2022 22:41:12 +0800 Chen Lin wrote: > > >> The sample code above cannot completely solve the current problem. > > >> For example, when fragsz is greater than PAGE_FRAG_CACHE_MAX_SIZE(32768), > > >> __page_frag_cache_refill will return a memory of only 32768 bytes, so > > >> should we continue to expand the PAGE_FRAG_CACHE_MAX_SIZE? Maybe more > > >> work needs to be done > > > > > >Right, but I can think of two drivers off the top of my head which will > > >allocate <=32k frags but none which will allocate more. > > > > In fact, it is rare to apply for more than one page, so is it necessary to > > change it to support? > > I don't really care if it's supported TBH, but I dislike adding > a branch to the fast path just to catch one or two esoteric bad > callers. > > Maybe you can wrap the check with some debug CONFIG_ so it won't > run on production builds? Also the example used here to define what is triggering the behavior is seriously flawed. The code itself is meant to allow for order0 page reuse, and the 32K page was just an optimization. So the assumption that you could request more than 4k is a bad assumption in the driver that is making this call. So I am in agreement with Kuba. We shouldn't be needing to add code in the fast path to tell users not to shoot themselves in the foot. We already have code in place in __netdev_alloc_skb that is calling the slab allocator if "len > SKB_WITH_OVERHEAD(PAGE_SIZE)". We could probably just add a DEBUG wrapped BUG_ON to capture those cases where a driver is making that mistake with __netdev_alloc_frag_align.