Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp568949ybg; Tue, 28 Jul 2020 13:03:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy04G5ynSZwnyr5SdIL7h86NJOBBykBnOD270kw5WhcnRCac92HrGIZ/uB7cT/qjrNn+qwE X-Received: by 2002:a50:ec0c:: with SMTP id g12mr21147282edr.27.1595966597953; Tue, 28 Jul 2020 13:03:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595966597; cv=none; d=google.com; s=arc-20160816; b=np6rXCUgRwx1CSAhUlYOmQ78RhVeEi1v5od87imyVw9ZQ/ZI9GMQk7F0+xjmgd3XKP 1ueJy2yUh/HKAh00QxxwOhv+I+3ZzvIKoLnbpAgKLP50QSml0FXoEXwmbtceWBiSXa+5 /Ck1DffQBu1HGG9xcQs4ehitT9LVC5nPp/5CwFpru7RIxbugT+MNihJyybMinpOEBQtH o/ZkmmcF8tiJECzGNLAUbdtt/vBfQNkRRAspQlP7raNNXyAViuiQ5+eGef95O0gMcth7 iY6IV2RSGoPjunjZqaEuAsk390eYSAjCx/4dqyXgRvvWgW2rPSvRpum0L/3NnyKmJcs/ digg== 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=gOr8dfaejifYw9jU6Kda38E3nkEbRCrHeHIL/mLht1M=; b=kSK+f6gyvkMHarhxccmSIBeOOLI/7UKXWTd7BYXiaLdZsXK3N2L0pTM68tONtAHygr kU1nGcBfHnmZU6KNheRbmplXq3S8UraD+sSjYerW3Gq57f5ZZazNyH+Cx0FDPCDmjdzm ONQDMF+AMtoat0H/TqRkONrGFc8TvOYK2eZMVsvc/5ikvKiMTh+33KOVQgwEKcaPvvFd cFovvcyACPS8faM5Dmy8A3MOwTpN/N6WBVNAUdeLfpd7jjjvlX/3M3ijHXhlEVl6ssIl 5KbGXrvQNPz3XGUEZ9imSL95fVR4rsvMtYVn8CBupDOJfPbSN5Ivfm8DqAUw/c6YGCoX Qv7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=otDe5YRw; 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 n25si3794580ejs.131.2020.07.28.13.02.55; Tue, 28 Jul 2020 13:03:17 -0700 (PDT) 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=20161025 header.b=otDe5YRw; 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 S1732671AbgG1TRE (ORCPT + 99 others); Tue, 28 Jul 2020 15:17:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729133AbgG1TRD (ORCPT ); Tue, 28 Jul 2020 15:17:03 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C073C061794; Tue, 28 Jul 2020 12:17:03 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id b79so19785279qkg.9; Tue, 28 Jul 2020 12:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gOr8dfaejifYw9jU6Kda38E3nkEbRCrHeHIL/mLht1M=; b=otDe5YRwMr9ZjZkUAfDqHdRBs1piZUTe4CTkYv5N3vMilg+mwSd8u3nh4gsItkTo7x keGv4P2iTlq5DIJzJbBMN4GTDiOMD0OpJh1C2xP3g76mfiKGLMDy95jV6wJvHN/3sJmr mfk8p/IBXfxF+72g5+Qndb/0bmn+YszTDATRnNlgDVDtEaz7a4ax1jGDLrpcj2KFhDlm Q7ydb47hnhDV3tab+g7WDUAhUX+rkiq43CLewaraeGHwV047qEpRBRM8Fy5eKU5uNXeY hK52o5YD5CrotoRkYnlXey5UPBLKr8Mvz0KnkI1keJ43PNod7JGSjVNEwkF+sycxnOUC Udxw== 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=gOr8dfaejifYw9jU6Kda38E3nkEbRCrHeHIL/mLht1M=; b=WjsS7K/bShsv4h95+KvPV365kVrv7MvjmNC7TbGWF42ZgvKeMrP3G5Y35opFIxzRX3 fjijdVG860/kW0ipkK+Pk/WMrpmmrn3yccI33QpMtDtnQ1hR7vz1LLPDBXd6OmTg6EfV 6t6AhI1lJrJkJYnuq/ozEVUHp1vRVfgNfd9as2LwTb5YLtZhtEL5nUa+xJ8lqwNdAlHJ CEFyTm6fG9FdcVsSRMs8enoPXRRvIWxDpUqy657hLzyENFU/LHtU9tWZTH6ZkGuhUm65 JOhIu3ScmZ9vQE3/zRZQJYVGhcDg/lXAY6fV/O3famQB02NwALF0F15kXtEcQPyfImjl IjTw== X-Gm-Message-State: AOAM53175GuBPsR8Yd0FhMvk8AnZWQ4ni7tBpEEqQAE3fbS9GrN4oLex mn6QcbMVsJxQ71tVdkx/H3dp/QzTuNYKmEfOmAw= X-Received: by 2002:a05:620a:4c:: with SMTP id t12mr3962581qkt.449.1595963822395; Tue, 28 Jul 2020 12:17:02 -0700 (PDT) MIME-Version: 1.0 References: <20200727184506.2279656-1-guro@fb.com> <20200727184506.2279656-28-guro@fb.com> <20200728190830.GB410810@carbon.DHCP.thefacebook.com> In-Reply-To: <20200728190830.GB410810@carbon.DHCP.thefacebook.com> From: Andrii Nakryiko Date: Tue, 28 Jul 2020 12:16:51 -0700 Message-ID: Subject: Re: [PATCH bpf-next v2 27/35] bpf: eliminate rlimit-based memory accounting infra for bpf maps To: Roman Gushchin Cc: Song Liu , bpf , Networking , Alexei Starovoitov , Daniel Borkmann , Kernel Team , open list 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 Tue, Jul 28, 2020 at 12:09 PM Roman Gushchin wrote: > > On Mon, Jul 27, 2020 at 11:06:42PM -0700, Song Liu wrote: > > On Mon, Jul 27, 2020 at 10:58 PM Andrii Nakryiko > > wrote: > > > > > > On Mon, Jul 27, 2020 at 10:47 PM Song Liu wrote: > > > > > > > > On Mon, Jul 27, 2020 at 12:26 PM Roman Gushchin wrote: > > > > > > > > > > Remove rlimit-based accounting infrastructure code, which is not used > > > > > anymore. > > > > > > > > > > Signed-off-by: Roman Gushchin > > > > [...] > > > > > > > > > > static void bpf_map_put_uref(struct bpf_map *map) > > > > > @@ -541,7 +484,7 @@ static void bpf_map_show_fdinfo(struct seq_file *m, struct file *filp) > > > > > "value_size:\t%u\n" > > > > > "max_entries:\t%u\n" > > > > > "map_flags:\t%#x\n" > > > > > - "memlock:\t%llu\n" > > > > > + "memlock:\t%llu\n" /* deprecated */ > > > > > > > > I am not sure whether we can deprecate this one.. How difficult is it > > > > to keep this statistics? > > > > > > > > > > It's factually correct now, that BPF map doesn't use any memlock memory, no? > > Right. > > > > > I am not sure whether memlock really means memlock for all users... I bet there > > are users who use memlock to check total memory used by the map. > > But this is just the part of struct bpf_map, so I agree with Andrii, > it's a safe check. > > > > > > > > > This is actually one way to detect whether RLIMIT_MEMLOCK is necessary > > > or not: create a small map, check if it's fdinfo has memlock: 0 or not > > > :) > > > > If we do show memlock=0, this is a good check... > > The only question I have if it's worth checking at all? Bumping the rlimit > is a way cheaper operation than creating a temporarily map and checking its > properties. > for perf and libbpf -- I think it's totally worth it. Bumping RLIMIT_MEMLOCK automatically means potentially messing up some other parts of the system (e.g., BCC just bumps it to INFINITY allowing to over-allocate too much memory, potentially, for unrelated applications that do rely on RLIMIT_MEMLOCK). It's one of the reasons why libbpf doesn't do it automatically, actually. So knowing when this is not necessary, will allow to improve diagnostic messages by libbpf, and would just avoid potentially risky operation by perf/BCC/etc. > So is there any win in comparison to just leaving the userspace code* as it is > for now? > > * except runqslower and samples