Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1274520rdg; Fri, 13 Oct 2023 16:40:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHojezdKuxsldTVIj/PRSWASOnTg2HI5NA+a3NXouNZE9XybPZvZcxRaYa7dpiJ+/AIA+gS X-Received: by 2002:a05:6a21:a592:b0:133:8784:15f7 with SMTP id gd18-20020a056a21a59200b00133878415f7mr2258327pzc.14.1697240432615; Fri, 13 Oct 2023 16:40:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697240432; cv=none; d=google.com; s=arc-20160816; b=ktklIgBzLCgZC0v3CiMSLLnz2d9AO4zET3+pyvb/0ro08qACXw+iTAENbVAXvJX12+ lq7ypIp4YlA17ze3iLodt02MbvPhMJo1/LVCeUaiT2tpdTfj8EZqOI7wz9Zy7L04q3WK 4dLWM6tQvkdZx4iS8mm8G57bB9WmxQO+D7wqIS5ZxbUmWbfoZL2IL5NNUPkbtZHxxcV5 6BsYgAj3/DvvJqOpMP20dWAKaA62iNzHIHGFBqZ2oqrkaLCU3neKu/4HNDnt8LveRoBr KiWn6hPb9qWs9GCnMBUajDPGdJd+NGZUyNJw1quuLWVDlG3V+/GpVkkRMLR7DMYCWNQj IlAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=pZMXeX8OkkWzerz5yiQXw5yfg9lFss/9TZkgrpsJOBM=; fh=1jzAqlRx1VcZ6N18EMXCXMIpcYoqMwJ11G2WT/YDdP8=; b=XpH+cZAygFi+0OSZSZcRdJ2rOU2ccEN16KVq1vAeF2QUNJ4UwRubuJ7pzwcO5iUIAV CpoBFS/e/cKvckw4F/QWCall1Z0eVAuAb9SPxUsOTlfQH2nTYhkbTiSh6h5BuUXCLtLy 89C2HZw3FSxIK0ijjaFgeAJNYm745AlG/yb3+7S302drepJO+Qvbq6+RrZyYtwXcS4sT CA87xMZQLsyBJmgjgHVVvkN5BjPIZdMlxTbATfqECNIg3cufqzccwHxUE18Ad1oSCQua aYIZCri0uh6GvzcOhuIipO44DnuhDFKQnS2CLLVWb7k8EoA6nZP15gWKS2RYQec0K1vM CHuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id k184-20020a6384c1000000b005ac958aa98esi1879147pgd.797.2023.10.13.16.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 16:40:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 5416A80C843B; Fri, 13 Oct 2023 16:40:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231875AbjJMXkT convert rfc822-to-8bit (ORCPT + 99 others); Fri, 13 Oct 2023 19:40:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbjJMXkR (ORCPT ); Fri, 13 Oct 2023 19:40:17 -0400 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D4DFB7; Fri, 13 Oct 2023 16:40:16 -0700 (PDT) Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-27d4b280e4eso598460a91.1; Fri, 13 Oct 2023 16:40:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697240415; x=1697845215; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NVNwQqiVkrXjE6Ai1N/131eZHMwXAneNV9c8J7fw4cE=; b=P+f/IVMG0eCNDesMou5YKY6mjKPFjHy6liEHqMjKD4ZX6+/00rxMkaJ7W//fbwlKHk vH/9sSrcSXw5o/k4r2VnI6hstgZVoTnKdVvhKwJ0pAQ6VqgmlK+17sH0ucDB27robipU Ahq/0lcXw/B6hRPT8oTedSLBrdVK3J6aS2RJ57xAXHTrjdB/pvpKQ238iBSUAY2bpDFQ 0L+qdpmWf0GlPACYThlqlVjYlAt894nVnXtfppaTsSU7AqEXVGpNWjhjeY5yKzhpt7Ep QwCpoUDVArKaGOTsKGvl7OclX+O6NbDoOVENkQJ5fP8bZ93oJTqSnw+0/f1gMfqCkhYd eWuw== X-Gm-Message-State: AOJu0Yxx9lLpefY88PGNtHckYvS7NUgyshOqVX/ZRuJ9LUh6/HT7dQH/ tydbsmLC6Krhsv4W7kHnPvLLHBcX8TWrU5UECP4= X-Received: by 2002:a17:90a:5ac6:b0:27d:2db5:62c9 with SMTP id n64-20020a17090a5ac600b0027d2db562c9mr2324253pji.0.1697240415439; Fri, 13 Oct 2023 16:40:15 -0700 (PDT) MIME-Version: 1.0 References: <20230928235018.2136-1-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Fri, 13 Oct 2023 16:40:04 -0700 Message-ID: Subject: Re: [PATCH] perf lock contention: Clear lock addr after use To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Ian Rogers , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Song Liu , Hao Luo , bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 13 Oct 2023 16:40:30 -0700 (PDT) On Fri, Oct 13, 2023 at 4:00 PM Arnaldo Carvalho de Melo wrote: > > Em Thu, Sep 28, 2023 at 04:50:18PM -0700, Namhyung Kim escreveu: > > It checks the current lock to calculated the delta of contention time. > > > The address is saved in the tstamp map which is allocated at begining of > > contention and released at end of contention. > > > > But it's possible for bpf_map_delete_elem() to fail. In that case, the > > How can it fail? > > You do: > > pelem = bpf_map_lookup_elem(&tstamp, &pid); > if (!pelem || pelem->lock != ctx[0]) > return 0; > > So it is there, why would the removal using the same key fail? It can fail when it doesn't get a lock for the internal bucket. See kernel/bpf/hashtab.c::htab_map_delete_elem(). But I'm not sure whether that's actually possible in this case. > > The patch should work as-is, I'm just curious about what would make > there removal of a map entry that was successfully looked up on the same > contention_end prog to fail when being removed... Now I'm seeing some rare error cases like a spinlock wait is longer than a minute. I suspect a bug in this code and try to be more defensive. Thanks, Namhyung