From patchwork Mon Feb 24 22:42:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 1243657 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=L0X+Q/At; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48RHC814f4z9sQx for ; Tue, 25 Feb 2020 09:42:59 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 38A74877F1; Mon, 24 Feb 2020 22:42:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0H-8OAfaPUHf; Mon, 24 Feb 2020 22:42:56 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 844198777B; Mon, 24 Feb 2020 22:42:56 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 79471C1D89; Mon, 24 Feb 2020 22:42:56 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 38249C0177 for ; Mon, 24 Feb 2020 22:42:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 27D1F8638E for ; Mon, 24 Feb 2020 22:42:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iW3sIQNZn1xa for ; Mon, 24 Feb 2020 22:42:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by fraxinus.osuosl.org (Postfix) with ESMTPS id B6BAA86055 for ; Mon, 24 Feb 2020 22:42:53 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id j7so4645353plt.1 for ; Mon, 24 Feb 2020 14:42:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jPJTeDm4jiGlrzCd+TuP0V4FVeqKlaC8qIb9NrNYZdM=; b=L0X+Q/Atm9VlS44I1YADim1IuUKPsUGO4neNNjE+gqvbdg5azJkzjfgEYGXAEl+9x0 zawtq1zv0+V0CmurTOrJ1dZDjUlT0ifUboiylj7i2WvQeZ/nT9NgTKeMrxV9Uz7SnFe5 DBY3/oOa68Ls15GYHGvmQxyLA1eE+3T6KDiQYRdPWqGpjSYh4EHir4OzwaxudLrUmoad yd8K/HS8++f4YVymo8po2Pd3Emexa8C9ro+65CrgYd3VddS4DW9tltEh14bPZZmqFj5A KEWupIBmWocFq7v7qMVEG45U/SvBXmTKKKLiHIj+vDGatbDLFAwKxdTNRYNW8Uo+eDlb sl2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jPJTeDm4jiGlrzCd+TuP0V4FVeqKlaC8qIb9NrNYZdM=; b=TTZilvARo6c0Vu3itYIStip4mZa9Z/yaPMFcuRnlqRkmKhy4Ip9klwj3fqSZC0ywxN +KXU893du/ADKdxkMy6W0oN4e/qnNXt+hdY9kNRzIzukCyBbQEGTzSWfuTdEwmwFO7cs UczAdi47LWVX5nhkbmZ+VKkVag3iljB1CRu7NPg04fyaEt4oMTA0wRpJNuM0h8k/W7Hh PINLTi98ahoVh+yY1W4LuBOD8cVbMEpdWA5kAXUw0A7wD9wQjke+hqgXxv8pRRE2ZpXW 4tLy65QU1cE6WFM916MGyxuXnDhbmtS275hSc2e8RhQSoESTKdUYLm6t0Nv3QtemHVHZ YVPA== X-Gm-Message-State: APjAAAWiwoRJ1DZ9hhLNXBbeYpDNYCjrNMaNpZMCfXJFJj5d6LXsxbKD cv4gOEwHxFAcea1BF/E9FJnyKnkD0og= X-Google-Smtp-Source: APXvYqwMUj6mZZE+CvZJG7TdOHHCi8ei9X2HeQ1alMobAV/ubu9orysi4+VIrqr9UG7w2ACvAqPK6w== X-Received: by 2002:a17:90b:94c:: with SMTP id dw12mr1472598pjb.13.1582584172885; Mon, 24 Feb 2020 14:42:52 -0800 (PST) Received: from gizo.domain (97-115-113-182.ptld.qwest.net. [97.115.113.182]) by smtp.gmail.com with ESMTPSA id 133sm14320705pfy.14.2020.02.24.14.42.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Feb 2020 14:42:52 -0800 (PST) From: Greg Rose To: dev@openvswitch.org Date: Mon, 24 Feb 2020 14:42:33 -0800 Message-Id: <1582584158-16348-4-git-send-email-gvrose8192@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582584158-16348-1-git-send-email-gvrose8192@gmail.com> References: <1582584158-16348-1-git-send-email-gvrose8192@gmail.com> Subject: [ovs-dev] [PATCH 4/9] compat: Remove flex_array code X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Flex array support is removed since kernel 5.1. Convert to use kvmalloc_array instead. Signed-off-by: Greg Rose --- datapath/linux/compat/stt.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/datapath/linux/compat/stt.c b/datapath/linux/compat/stt.c index 21fef09..7b46d1a 100644 --- a/datapath/linux/compat/stt.c +++ b/datapath/linux/compat/stt.c @@ -13,7 +13,6 @@ #include #include -#include #include #include #include @@ -136,7 +135,7 @@ struct pkt_frag { }; struct stt_percpu { - struct flex_array *frag_hash; + struct pkt_frag *frag_hash; struct list_head frag_lru; unsigned int frag_mem_used; @@ -1079,8 +1078,7 @@ static struct pkt_frag *lookup_frag(struct net *net, int i; for (i = 0; i < FRAG_HASH_SEGS; i++) { - frag = flex_array_get(stt_percpu->frag_hash, - hash & (FRAG_HASH_ENTRIES - 1)); + frag = &stt_percpu->frag_hash[hash & (FRAG_HASH_ENTRIES - 1)]; if (frag->skbs && time_before(jiffies, frag->timestamp + FRAG_EXP_TIME) && @@ -1533,7 +1531,7 @@ static void clean_percpu(struct work_struct *work) for (j = 0; j < FRAG_HASH_ENTRIES; j++) { struct pkt_frag *frag; - frag = flex_array_get(stt_percpu->frag_hash, j); + frag = &stt_percpu->frag_hash[j]; if (!frag->skbs || time_before(jiffies, frag->timestamp + FRAG_EXP_TIME)) continue; @@ -1631,26 +1629,20 @@ static int stt_start(struct net *net) for_each_possible_cpu(i) { struct stt_percpu *stt_percpu = per_cpu_ptr(stt_percpu_data, i); - struct flex_array *frag_hash; + struct pkt_frag *frag_hash; spin_lock_init(&stt_percpu->lock); INIT_LIST_HEAD(&stt_percpu->frag_lru); get_random_bytes(&per_cpu(pkt_seq_counter, i), sizeof(u32)); - frag_hash = flex_array_alloc(sizeof(struct pkt_frag), - FRAG_HASH_ENTRIES, - GFP_KERNEL | __GFP_ZERO); + frag_hash = kvmalloc_array(sizeof(struct pkt_frag), + FRAG_HASH_ENTRIES, + GFP_KERNEL | __GFP_ZERO); if (!frag_hash) { err = -ENOMEM; goto free_percpu; } stt_percpu->frag_hash = frag_hash; - - err = flex_array_prealloc(stt_percpu->frag_hash, 0, - FRAG_HASH_ENTRIES, - GFP_KERNEL | __GFP_ZERO); - if (err) - goto free_percpu; } schedule_clean_percpu(); n_tunnels++; @@ -1691,7 +1683,7 @@ free_percpu: struct stt_percpu *stt_percpu = per_cpu_ptr(stt_percpu_data, i); if (stt_percpu->frag_hash) - flex_array_free(stt_percpu->frag_hash); + kvfree(stt_percpu->frag_hash); } free_percpu(stt_percpu_data); @@ -1718,11 +1710,11 @@ static void stt_cleanup(struct net *net) for (j = 0; j < FRAG_HASH_ENTRIES; j++) { struct pkt_frag *frag; - frag = flex_array_get(stt_percpu->frag_hash, j); + frag = &stt_percpu->frag_hash[j]; kfree_skb_list(frag->skbs); } - flex_array_free(stt_percpu->frag_hash); + kvfree(stt_percpu->frag_hash); } free_percpu(stt_percpu_data);