Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7369070rwb; Tue, 6 Dec 2022 05:03:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf48DpqzUy0JFgpN0Nd+EfsyF4L7/pBT+0bO/QAYdv6is5CQco6RNdV12g/QkFf5RD+WtYO3 X-Received: by 2002:a63:2117:0:b0:474:f7bd:9462 with SMTP id h23-20020a632117000000b00474f7bd9462mr60391669pgh.189.1670331808206; Tue, 06 Dec 2022 05:03:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670331808; cv=none; d=google.com; s=arc-20160816; b=OT/pEuJvjawsFtwx0hacS1PhiHMabEBlrVXGZ7IAOiZcllzQl/1qBm++i3c/DpOXqQ vMYa7zvsJcC/fl+/FpI6LbkvnSj2/gIMFPqvm+d/knFiMut13vn2aYqsfd/B9JizRW5k i3x5LAtETcsHla0eSfmk/FqnCwUs61sB1MVQR0IgSBa+PKmNfjjNYGG/vGZSkaVqjmqJ zDNc/m2rwOqGsIZfHcnlqBGfbRKxT+LUE/2kMQMYpmgaC2msd6wxofL2SuGpQDU50fUT hcgSlDXVK9zQ4Af6vdkGw+oZamSXICgP1zAsEwb4ug5pcVEWrziAa7umGUIOcEur970n vIIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=DHp3x7R/guV3hbeucoqTiz42buTvLFKB8vI9+m0vRAc=; b=uHfFn+hOMGJfYn4c20xtv10Z+ZOqErkyM2tnvb9ciK6SJU9JmOcU39+D9tBp9Oc5w5 waIYMK6VIhbDF63NMUinJ1g9WiArH5L1ybFxyryEtLXU+i570ZbH9sGHED7o6l2MIJDh QlRrmoINn690BrNEPqJgI/SgFLRvm9QjQvupPBX7GSI5ZQtCHn4VpB0tl+wJy9rd8biK lziXIbUa1pktPW4v55P0Q6V/pkiM5V9k6zrRDfaaW0NrqJmPzpr12Q2ds1KGMAzibAqE RaTI5i0HZK2hTadN098KcdKzvIm/+0rGxh4JG44h1FH8jCjyrQklp8KsvOJ/YWdNmfra G+gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=D8IwG+S5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mn22-20020a17090b189600b00219b3307f5fsi7726791pjb.45.2022.12.06.05.03.17; Tue, 06 Dec 2022 05:03:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=D8IwG+S5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234240AbiLFMdC (ORCPT + 80 others); Tue, 6 Dec 2022 07:33:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233909AbiLFMc4 (ORCPT ); Tue, 6 Dec 2022 07:32:56 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C0182937F for ; Tue, 6 Dec 2022 04:31:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670329918; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DHp3x7R/guV3hbeucoqTiz42buTvLFKB8vI9+m0vRAc=; b=D8IwG+S5zN1MXxryo/fCbh6Ukt/pyOIUP5D5x14+YyEC+gihSMfWQRGJ+dyT5pZ/BwytnZ cZcJS2nok0YWsMYa/Kn+uhFHXv2E+yFCzZ3ztYkBchEgJT6oTltkhSC71I/3u+Se9aYeTm SyIz9epZnF7Flo1uPGBcLpx9QaBryKA= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-16-lxacUxHPOuucCBWP_VAHDw-1; Tue, 06 Dec 2022 07:31:57 -0500 X-MC-Unique: lxacUxHPOuucCBWP_VAHDw-1 Received: by mail-wr1-f69.google.com with SMTP id w11-20020adfbacb000000b002418a90da01so3147729wrg.16 for ; Tue, 06 Dec 2022 04:31:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=DHp3x7R/guV3hbeucoqTiz42buTvLFKB8vI9+m0vRAc=; b=KR8kvcOHUboXz3GA8eeJoLWJPNOByY2uEt53yXW4nzWTQqPmbDy0aA+/SDPN9k+I+E NudbXnGhwT2KX8K51+VdfXRwRy0I9T/kCbB4/4lD7TZ1fYoCRWlzKhUDD0GECQFjofHa WV3Xia8uS581cGiLRRRySGckiIvMdINiMCahLmj+XO4KNhaTH98GSbDKFNPX/pH5S2fZ lsSIan/IGVnQgM9WX0dwwyRHjXwgjII55v0w8gy8FHDA8FNlGFHPXGKNPkUo8tw3CPZm 2Y0ifGc0VB1ImHMdbYrfj/T6oV8xHea5shSjt3Q/cnMobnckt6R/gEErRcmUeO342k+H OsbQ== X-Gm-Message-State: ANoB5pmTDtrmhxf/i4o3xQPtFcszXI2Tyl5wWSZo9LLlIYvhtQ+v9DME RtkpNWFeSi3cdHAqueEC481n1qLGIO6ima4L+ZSqQIKW6OtcYyKNdDo7U05m2UOvzBzAATwHBrO dPYcEn0uKA74V7+rY3SxRzvdp X-Received: by 2002:adf:db85:0:b0:241:bfd7:de7 with SMTP id u5-20020adfdb85000000b00241bfd70de7mr50298110wri.254.1670329915715; Tue, 06 Dec 2022 04:31:55 -0800 (PST) X-Received: by 2002:adf:db85:0:b0:241:bfd7:de7 with SMTP id u5-20020adfdb85000000b00241bfd70de7mr50298102wri.254.1670329915442; Tue, 06 Dec 2022 04:31:55 -0800 (PST) Received: from gerbillo.redhat.com (146-241-106-100.dyn.eolo.it. [146.241.106.100]) by smtp.gmail.com with ESMTPSA id r2-20020a056000014200b002422bc69111sm20743265wrx.9.2022.12.06.04.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 04:31:55 -0800 (PST) Message-ID: <256f533f019b6392b41701707eb7aa056b2f16c0.camel@redhat.com> Subject: Re: [PATCH net-next v3 1/4] net: microchip: vcap: Add vcap_get_rule From: Paolo Abeni To: Horatiu Vultur , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, Steen.Hegelund@microchip.com, lars.povlsen@microchip.com, daniel.machon@microchip.com, richardcochran@gmail.com, UNGLinuxDriver@microchip.com, olteanv@gmail.com Date: Tue, 06 Dec 2022 13:31:53 +0100 In-Reply-To: <20221203104348.1749811-2-horatiu.vultur@microchip.com> References: <20221203104348.1749811-1-horatiu.vultur@microchip.com> <20221203104348.1749811-2-horatiu.vultur@microchip.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Sat, 2022-12-03 at 11:43 +0100, Horatiu Vultur wrote: > @@ -632,32 +264,22 @@ static int vcap_show_admin(struct vcap_control *vctrl, > struct vcap_admin *admin, > struct vcap_output_print *out) > { > - struct vcap_rule_internal *elem, *ri; > + struct vcap_rule_internal *elem; > + struct vcap_rule *vrule; > int ret = 0; > > vcap_show_admin_info(vctrl, admin, out); > - mutex_lock(&admin->lock); > list_for_each_entry(elem, &admin->rules, list) { Not strictly related to this patch, as the patter is AFAICS already there in other places, but I'd like to understand the admin->rules locking schema. It looks like addition/removal are protected by admin->lock, but traversal is usually lockless, which in turn looks buggy ?!? Note: as this patch does not introduce the mentioned behavior, I'm not going to block the series for the above. Thanks, Paolo > - ri = vcap_dup_rule(elem); > - if (IS_ERR(ri)) { > - ret = PTR_ERR(ri); > - goto err_unlock; > + vrule = vcap_get_rule(vctrl, elem->data.id); > + if (IS_ERR_OR_NULL(vrule)) { > + ret = PTR_ERR(vrule); > + break; > } > - /* Read data from VCAP */ > - ret = vcap_read_rule(ri); > - if (ret) > - goto err_free_rule; > + > out->prf(out->dst, "\n"); > - vcap_show_admin_rule(vctrl, admin, out, ri); > - vcap_free_rule((struct vcap_rule *)ri); > + vcap_show_admin_rule(vctrl, admin, out, to_intrule(vrule)); > + vcap_free_rule(vrule); > } > - mutex_unlock(&admin->lock); > - return 0; > - > -err_free_rule: > - vcap_free_rule((struct vcap_rule *)ri); > -err_unlock: > - mutex_unlock(&admin->lock); > return ret; > }