Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1471532imm; Fri, 7 Sep 2018 00:24:00 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdas7bBb9cEwHgWH1aejbf60VstPsxN90tLnvkU9vO8jHMMhd+CkvwKzDj3K/+2FFfFu1KoU X-Received: by 2002:a17:902:6bc5:: with SMTP id m5-v6mr6514479plt.274.1536305040243; Fri, 07 Sep 2018 00:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536305040; cv=none; d=google.com; s=arc-20160816; b=XRh3mYLR66wnX1xzcl5WyDK4uqYuf1XadRkw4dHN7JrsSA3A1EFCo7HoIW6yDD5c+v Jx5V7ymvPJ+6ojXZ581tcLwa6LfJvR9TGOHUPlclzeuBapB8n+EsCte5XLwXck/fgjax /VKzQheZBrfZ8JHCkmgQW6KI6Nrx1X8kWGi/Ulx1OrupibGDTZ7SC/JGo2U6AY94A7Jd pp5TELj6Fr3uCyAhrOPGTXE7t+IdHEk1zxL0B5Bv+YILDQOWiULxqrUF7hy3ibOoNGUr sFILGmvrT2IMHK0HJwmTBodeyGHCB30ISke+Dx7O8Bdcd87SvsX/hWPsBn5zzM4aA9Y9 LHZA== 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; bh=bQdvSyJjL7kdNmZznzkwVVDEJIzKHOjKsLidaYwNZSA=; b=h5MpawesJ38rJmOxQ5UlDOF40ZPLOJG+HYWm0hY+otPoew0pH1W8oEVcnSj/qChP2/ BMqQrKS3X6qQ4/1aNrAF91XyYtoJuLnznpvI0eK21kxEPzeRUGJuIEVF3P5vtIx7ybfE ZQ3i6JXVK6WmkB2eC1P19HcdaGn78T99o0k5+zaUyf3uOVfAVmFBLjs4tCgvxVe0dR5J KO0kO/WrvcEjr2hIXXtuVBvsoOqhebX5+8Nh4FUhF8/sNxCOQH+b8lwjfA8IRuIVgLD3 hgX8OgEvjm5uFdV4eXI9A2lwGQSf/fdQMxSAaxb3h5zcYx6exliTstFo8Hl9dOz0n0M4 4vnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Hyvk9ab7; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r3-v6si6921822plb.221.2018.09.07.00.23.43; Fri, 07 Sep 2018 00:24:00 -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=@google.com header.s=20161025 header.b=Hyvk9ab7; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727328AbeIGMBf (ORCPT + 99 others); Fri, 7 Sep 2018 08:01:35 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:39660 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725843AbeIGMBe (ORCPT ); Fri, 7 Sep 2018 08:01:34 -0400 Received: by mail-io1-f66.google.com with SMTP id l7-v6so809095iok.6 for ; Fri, 07 Sep 2018 00:22:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bQdvSyJjL7kdNmZznzkwVVDEJIzKHOjKsLidaYwNZSA=; b=Hyvk9ab7mcDbLaBQbIHx31rllq1u2zxShTyIG/i+ng9dY6LeYxZHtqnRm3dV++cZnN 68VLQBkpfX8ximN8yfudWYUwn7bqwnHzsHHHJScLuJJEAjVolZaCnvMYMmDNjT0iGM9h +tAPwr3W4QOEkQDiqIwgbqXn+YELtu4Q/Ic2DLbwBlV41lNbSC9h4f+1bH+oTP7QVYNS sHa/CzlJrIVzwuzJAoVWut++CIwjPG4LGUG/VWcPC16YrVwTZAKOSFbORP1mkJOxds98 fJAjFto7Vu/N8FXFKxKcH9kKwYIZv5fr+3pcgCtboCJy4eizzXb/KiYgECIvSxYdQrOV WtYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bQdvSyJjL7kdNmZznzkwVVDEJIzKHOjKsLidaYwNZSA=; b=lk7Pp3Gmw/RfWBjqWeMmkELLax6ofyMKLNuTjbCYVzCUdJhoS0DQw0A/Gfn2ChTtp3 OlRaOvh5SIzohiPniS8JgZ9NIAnToaXuTHUbn/8pdb6zWnMHlF1ndM32BPdl0BrlJHgm oMfbpxQWc/0NwNQoBlFR8hgaOor6zozsG+a9zDEJMz7voh9WwI0wgP+U1FYpnDg17FNK luRiVM2+YXh0Wh0Uo8F7SebLqfo/JhbfdZArAKBrJ/cpJnNze8MPqHh5WPtWri9otEd4 xUGLiCxbbanMTLiCTpQU5eZg9M+MfQfy0koFsGH4Vyn975el/MXydk8rdQ/31mIq3+oc CKOg== X-Gm-Message-State: APzg51CVrBrh3hdTR74VW+8cg733LweqdI3URvoAoH6fhBTQlQ1cdWHZ kSBAa5gyn5Q6A+2SewGJ1CHhSH+5lgJvR4jNBLG9oQ== X-Received: by 2002:a6b:8fd0:: with SMTP id r199-v6mr4912079iod.118.1536304919347; Fri, 07 Sep 2018 00:21:59 -0700 (PDT) MIME-Version: 1.0 References: <20180906192034.8467-1-olof@lixom.net> <20180907033257.2nlgiqm2t4jiwhzc@gondor.apana.org.au> In-Reply-To: From: Eric Dumazet Date: Fri, 7 Sep 2018 00:21:46 -0700 Message-ID: Subject: Re: [PATCH] net/sock: move memory_allocated over to percpu_counter variables To: Olof Johansson Cc: Herbert Xu , David Miller , Neil Horman , Marcelo Ricardo Leitner , Vladislav Yasevich , Alexey Kuznetsov , Hideaki YOSHIFUJI , linux-crypto@vger.kernel.org, LKML , linux-sctp@vger.kernel.org, netdev , linux-decnet-user@lists.sourceforge.net, kernel-team , Yuchung Cheng , Neal Cardwell 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 Fri, Sep 7, 2018 at 12:03 AM Eric Dumazet wrote: > Problem is : we have platforms with more than 100 cpus, and > sk_memory_allocated() cost will be too expensive, > especially if the host is under memory pressure, since all cpus will > touch their private counter. > > per cpu variables do not really scale, they were ok 10 years ago when > no more than 16 cpus were the norm. > > I would prefer change TCP to not aggressively call > __sk_mem_reduce_allocated() from tcp_write_timer() > > Ideally only tcp_retransmit_timer() should attempt to reduce forward > allocations, after recurring timeout. > > Note that after 20c64d5cd5a2bdcdc8982a06cb05e5e1bd851a3d ("net: avoid > sk_forward_alloc overflows") > we have better control over sockets having huge forward allocations. > > Something like : Or something less risky : diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 7fdf222a0bdfe9775970082f6b5dcdcc82b2ae1a..0aee80b6966cb2898e46350c761f9eb431ff1206 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -604,7 +604,8 @@ void tcp_write_timer_handler(struct sock *sk) } out: - sk_mem_reclaim(sk); + if (tcp_under_memory_pressure(sk)) + sk_mem_reclaim(sk); } static void tcp_write_timer(struct timer_list *t)