From patchwork Tue Nov 17 02:55:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 11911289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E052EC6369E for ; Tue, 17 Nov 2020 02:55:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7B721246AD for ; Tue, 17 Nov 2020 02:55:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="BYazDK6V" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B721246AD Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=fb.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 166C36B006C; Mon, 16 Nov 2020 21:55:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0EF8B6B006E; Mon, 16 Nov 2020 21:55:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E61156B0071; Mon, 16 Nov 2020 21:55:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0061.hostedemail.com [216.40.44.61]) by kanga.kvack.org (Postfix) with ESMTP id AB6AA6B006C for ; Mon, 16 Nov 2020 21:55:39 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 58A408249980 for ; Tue, 17 Nov 2020 02:55:39 +0000 (UTC) X-FDA: 77492394798.06.tin55_37121dc2732e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 22EA2100410C2 for ; Tue, 17 Nov 2020 02:55:39 +0000 (UTC) X-HE-Tag: tin55_37121dc2732e X-Filterd-Recvd-Size: 4206 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Tue, 17 Nov 2020 02:55:38 +0000 (UTC) Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AH2nTp7031204 for ; Mon, 16 Nov 2020 18:55:37 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=lnrDosrqi+a8PqEWb1gLJQgKjxqxqhn/WbfOUeEH/TE=; b=BYazDK6VvSxV5DjQ4S9RHAq9OoRel1HhpW56fQ6lH97wBQW5/+8TxOq3UmOtlrXq3vYY jKVexY4q3RbGao/ApKDd7180+xSaFeXn8wiLV/xoBVhZIbnR81McUEu2bMxqDyA8FGw7 150/7BJPr211Jw5pcMXq3gTgttcin5p9vhE= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com with ESMTP id 34uwyg2pnp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 16 Nov 2020 18:55:37 -0800 Received: from intmgw002.41.prn1.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:11d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 16 Nov 2020 18:55:36 -0800 Received: by devvm3388.prn0.facebook.com (Postfix, from userid 111017) id 002FDC5F7DE; Mon, 16 Nov 2020 18:55:33 -0800 (PST) From: Roman Gushchin To: CC: , , , , , , , Subject: [PATCH v6 16/34] bpf: refine memcg-based memory accounting for sockmap and sockhash maps Date: Mon, 16 Nov 2020 18:55:11 -0800 Message-ID: <20201117025529.1034387-17-guro@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20201117025529.1034387-1-guro@fb.com> References: <20201117025529.1034387-1-guro@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312,18.0.737 definitions=2020-11-16_13:2020-11-13,2020-11-16 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 bulkscore=0 mlxlogscore=998 priorityscore=1501 clxscore=1015 mlxscore=0 impostorscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 suspectscore=13 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011170022 X-FB-Internal: deliver 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: Include internal metadata into the memcg-based memory accounting. Also include the memory allocated on updating an element. Signed-off-by: Roman Gushchin Acked-by: Song Liu --- net/core/sock_map.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/core/sock_map.c b/net/core/sock_map.c index ddc899e83313..30455d1952e7 100644 --- a/net/core/sock_map.c +++ b/net/core/sock_map.c @@ -39,7 +39,7 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr) attr->map_flags & ~SOCK_CREATE_FLAG_MASK) return ERR_PTR(-EINVAL); - stab = kzalloc(sizeof(*stab), GFP_USER); + stab = kzalloc(sizeof(*stab), GFP_USER | __GFP_ACCOUNT); if (!stab) return ERR_PTR(-ENOMEM); @@ -975,7 +975,8 @@ static struct bpf_shtab_elem *sock_hash_alloc_elem(struct bpf_shtab *htab, } } - new = kmalloc_node(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN, + new = kmalloc_node(htab->elem_size, + GFP_ATOMIC | __GFP_NOWARN | __GFP_ACCOUNT, htab->map.numa_node); if (!new) { atomic_dec(&htab->count); @@ -1116,7 +1117,7 @@ static struct bpf_map *sock_hash_alloc(union bpf_attr *attr) if (attr->key_size > MAX_BPF_STACK) return ERR_PTR(-E2BIG); - htab = kzalloc(sizeof(*htab), GFP_USER); + htab = kzalloc(sizeof(*htab), GFP_USER | __GFP_ACCOUNT); if (!htab) return ERR_PTR(-ENOMEM);