Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp208974pxf; Wed, 31 Mar 2021 01:01:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/V55IdQJCjDAJvKPyUx9VgAbWKznIqlageITIUm3d6utj9kCsn094GO5/PyMCuvui8xqd X-Received: by 2002:a50:ed96:: with SMTP id h22mr2090997edr.39.1617177699700; Wed, 31 Mar 2021 01:01:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1617177699; cv=pass; d=google.com; s=arc-20160816; b=PKZ1hUN/HNvNlOgWFm9MUb91rrEHPxqMscWUSo5zpqFxCfhVaqR4FUht2dVYEfUBDQ l1FWTPeDya6TN9vL93d3LXvHMcpeeUtqSpn/CX+OMTFjyPnPgXV+PaVSMpZstyz2jAiL 7uIRvolPSn+8Keaqq3eFNsorR8+gvYwtKKUR96M8XFOCtkb6YaosVGeiqRLGGd4Xk87O 7phD4hLCu5hMpVn7vt87BqOYMf7mR7w9e88Gv9Fh8rRD056fiDpP7aBQje9zIqdZ3/+Q XXrJUVvHL2q/fBsYyae7xoxQgv+rJQTw/z7aRm84k4nC05zb1rmQlV2LUJr1BNFJ2uiG S6Vw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:in-reply-to:subject :cc:to:from:user-agent:references:dkim-signature; bh=GCexuLTxgP1kr4moKiS3JDsfUSw4LNw/1gqSahYVQ/w=; b=fERM3PbDgNcnbDELxpQ2WUjh8CCuuf3AOaikPEpdKAgusD9UWTr/b4pef9hiQfG90u BrTBDDxC4xvCGVN4VovhlFmpl1YaWvWnBeWpGPFlO+64+qIrX6twARfp1Qfg30j0Bg/K R1gmrBfb3jdRU1XtxtB7wDKHX3ADefeZaGaLpo0FdGqkLSDh/2lZDg2+vH6RUEyfynci ty71kPCh5xqOTBcuQXemEI0c1t1bw2t3E4irE+5/LFpnwVKM0snhcT6rDbcRpXTl/9Es uC6JhW8m0wcYtqYB0Or0OoyZ1GPC2bw5CeP7P/LmmvKCkk3/OIP/Kz/zEg/JJJZemHQx rN5A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=ZYxbi4Lt; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x10si1151066eds.158.2021.03.31.01.01.16; Wed, 31 Mar 2021 01:01:39 -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=@Nvidia.com header.s=selector2 header.b=ZYxbi4Lt; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233925AbhCaH7u (ORCPT + 99 others); Wed, 31 Mar 2021 03:59:50 -0400 Received: from mail-co1nam11on2069.outbound.protection.outlook.com ([40.107.220.69]:43565 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234273AbhCaH7q (ORCPT ); Wed, 31 Mar 2021 03:59:46 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eRtYawaGqvWuj9c03ddGU81p7r0k7tiqvxFtPGJkCd/9VFSwEH256C99rNE3gOtySf1M4loAo58X/tpeAvNXfkwDLYpv0HpHwNQMOT9602n1dAAISQpC0ElzJuS2OqcLjeqBCllrjPmjlNrs3dKSk7md4OALlrfzbYT8792RTj5XC/UevPOrnERukqx9ATr6tfRuqiuv2xoYQlg5zKeIQmzq0+Hw4dd8ajsgRpbUT81UDMQzIoxmqH0Fz9aGYRkrRQYjNXaLsMcVyuxkSoDpSSjMEn0TybSPo6KX8SFYfsj4d94qyTn9/kiE63e68lVx7gP8GttcFsijueW9b4Jh+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GCexuLTxgP1kr4moKiS3JDsfUSw4LNw/1gqSahYVQ/w=; b=TzuwIzXZRk6sADvVUgigk6atG+AY71DHb6IijTnyiHSGIppgRbCRvxoBvAk9IFcFvowkCQSPPbQvTdjlKy0NsQVCw4VZxFNQtJaZjgYyobBJb9HMIIdCmuGmyqodMiHTsOCcCrtY0K5IY+TBL8waIIjmTKKn8+O9bMYEUAzh1EoYH5nxMv/vUW2ZvGhVRm64ivNrft+JiZQeJzGXUYkpA5FrpYoFBKit+PgVaR6TMhuQ1TVBBvt9Dux1Q9BwbO79TskG7y290rGKpFEtn2PUOi3/Wk/8i090T5sOUXSL7AcFiYV77ve6sUehEFTDU00zhYwrc4DOtcPy1vyQLRfHMQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GCexuLTxgP1kr4moKiS3JDsfUSw4LNw/1gqSahYVQ/w=; b=ZYxbi4LtxB6UjsdY8Wwv4/oE8UdM9id1v4aW4iuEB13FXCYpd8iD+0dt/5bpRfliAO8aayp5JfmWtGCfRWMzop2swHHoFj2gnlKaGIrAKa8fTcJkk69lW5TbpylDTG6gGVJ8yHuHaZgqf6ifU1xLDP0PNZU3e0P3PoASxyMGFwDVI0hFG2xnOcx+gBgtKZMxNGgoMZMywACbRyL5MQQmWOHtwU9xo1kYOWDiwVFEMQHbzrzPg44lAcIAkHwlhpEpuLx31Dn0G78RI9sTkWhKRPD6Hbr/OoJjeemIoke/t1Gg1zt25tWLGTI/ReKQJMLFCGtmj06EXhtEydsUsDW5sQ== Received: from MW4PR03CA0165.namprd03.prod.outlook.com (2603:10b6:303:8d::20) by CH2PR12MB4262.namprd12.prod.outlook.com (2603:10b6:610:af::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.26; Wed, 31 Mar 2021 07:59:44 +0000 Received: from CO1NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::19) by MW4PR03CA0165.outlook.office365.com (2603:10b6:303:8d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.26 via Frontend Transport; Wed, 31 Mar 2021 07:59:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT005.mail.protection.outlook.com (10.13.174.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.3955.18 via Frontend Transport; Wed, 31 Mar 2021 07:59:44 +0000 Received: from reg-r-vrt-018-180.nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 31 Mar 2021 07:59:40 +0000 References: <20210329225322.143135-1-memxor@gmail.com> User-agent: mu4e 1.4.10; emacs 27.1 From: Vlad Buslov To: Cong Wang CC: Kumar Kartikeya Dwivedi , David Miller , Jamal Hadi Salim , Jiri Pirko , Jakub Kicinski , LKML , Linux Kernel Network Developers , Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= Subject: Re: [PATCH v2 1/1] net: sched: bump refcount for new action in ACT replace mode In-Reply-To: Date: Wed, 31 Mar 2021 10:59:37 +0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 52b5c3a5-cab5-4afc-6d15-08d8f41af21d X-MS-TrafficTypeDiagnostic: CH2PR12MB4262: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EwtG37koOeF0pVWrrzMwiWBA3IXfornRFPS0PDSCFLJIKkzBXLTTB5ntDZoGSJNy6G5/dRkoNxORah/GVI+PbJ9AMr7lnJABy15MQ8bfEMnhGmE0bWKoUGN4DLSuv3YJq5LABXTgtVjtgOT56t4BMC2efp8rrx0fUGlMcHzQQZZ43zMCiXsd06tK/AJli6j2CI8b5i+7WugxyT7KFDSNQY2AvnmLTiMhnE6yNXowy2iF+oNaLuF11MLIHsZAihHbUqHYwEMnjI3w1SNtgvQ+mf9jHhpLt5922UxDnOw4GOu3CohnXmRaqKEF0iTG0OKLioKzJqPkjoGuA+aED9GafTCVyrTxrsvZGaEhac1Ouqv9kLBTQuRZQPP9RGO6GPF+d+0P/TEshTnmduoZWqG8vUyFdxic5yt70NN82iegARc42W7hVzo53bkGMQuzUCAA9flwY5BrA6bUJdMGHj8kbIQlGwwDFGM60+QqKLL7Db3Faxv+U4znC4xN5UrAspH0PH58I+dTh0KFLsqZ3C5kdOQs9btiMxm38rlBDse6fwR9Y4Kob8cYulecsQXxKpVovLgwrU5GYNoizUilr4PSDu1HLOdjretmcNqGqURMgnR0aWEUUdDzHL3Y+jvwOdwxN1pXILrixVXZFR/TUSOKUhs9zFyAK0uvsjsXGPqnKBg= X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(396003)(136003)(39860400002)(376002)(346002)(46966006)(36840700001)(7696005)(36906005)(36756003)(4326008)(186003)(426003)(36860700001)(7636003)(2616005)(2906002)(316002)(336012)(54906003)(26005)(356005)(53546011)(82740400003)(83380400001)(8676002)(5660300002)(8936002)(70586007)(16526019)(478600001)(6666004)(86362001)(47076005)(82310400003)(70206006)(6916009);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2021 07:59:44.0237 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 52b5c3a5-cab5-4afc-6d15-08d8f41af21d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4262 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 31 Mar 2021 at 07:40, Cong Wang wrote: > On Mon, Mar 29, 2021 at 3:55 PM Kumar Kartikeya Dwivedi > wrote: >> diff --git a/net/sched/act_api.c b/net/sched/act_api.c >> index b919826939e0..43cceb924976 100644 >> --- a/net/sched/act_api.c >> +++ b/net/sched/act_api.c >> @@ -1042,6 +1042,9 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, >> if (err != ACT_P_CREATED) >> module_put(a_o->owner); >> >> + if (!bind && ovr && err == ACT_P_CREATED) >> + refcount_set(&a->tcfa_refcnt, 2); >> + > > Hmm, if we set the refcnt to 2 here, how could tcf_action_destroy() > destroy them when we rollback from a failure in the middle of the loop > in tcf_action_init()? > > Thanks. Hmm, you might be right. Also, the error handling code in tcf_action_init() looks incorrect: err: tcf_action_destroy(actions, bind); err_mod: for (i = 0; i < TCA_ACT_MAX_PRIO; i++) { if (ops[i]) module_put(ops[i]->owner); } return err; It looks like here the modules for all actions that successfully completed their init has already been release by either tcf_action_init_1() on action overwrite or by tcf_action_destroy() on action create. I'll try to come up with tests that validate these corner cases. Regards, Vlad