From patchwork Mon Jul 1 22:53:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijian Zhang X-Patchwork-Id: 13718718 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C09916DC09 for ; Mon, 1 Jul 2024 22:53:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719874439; cv=none; b=OsMHP222g5CDSdRjvEPMAzOvmSZhLiC8DEZn9E/4vi44BM0rp7iVxp44jOsfP8kX/cYKRDZOFU9Ljt0b6YMjfVgh+2rLaMTvsBfQHia/5I1Yucgt5m2CC9DcjX1s+q1HHFTIeVb7672FKidW/V1L96gAxc8j9lQkmftbRIUjf30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719874439; c=relaxed/simple; bh=ixwDpOmaHYDB1m6ExiTtrSbDMWU2C23t3iqGXTcAASo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ewwoqJIj3IHsJjlEQqRm5cEdlFT6m9UQ9Scm0qxDi46a8qZlSAnlCkq2vX6MhCTke1vv1zptauh+EZhXWm+RuForppUCgmNurkAtVRFlFk5a3tF8tgifAADWrnWRca7OAyrupiYLty56WoxcSqrElC/giwISjGo17H6a38VNRV0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=KEy3Jg7E; arc=none smtp.client-ip=209.85.222.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="KEy3Jg7E" Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-79c05313ec8so187668785a.3 for ; Mon, 01 Jul 2024 15:53:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1719874435; x=1720479235; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5eoI38xui1xgULGcdpxHaWYoWkSLh1oKyKiReT5u/ZA=; b=KEy3Jg7EbE+1tP7WvjKyrDLo4N8Bne4gBMpm+6It1jH/VDxlr6yZiFl1mM3Y5ToZyW wQKPwMIr80Db+Rf105aZxjEi2+71dhnHjWX5ojwQwd2doDjNYxsq115P3f1NA/59HBDF 0NU/c+vIUESEIIlc+6DVTEwB7hL1Jo1iEdUJG08qyJnJQ/MV5hZiVJFLHyaLE/bhZ8w1 a6LKFxxtPGD0Of8NUZ4J7Y14PTJMNEgpTn236vvOI4TjteMI/sXuYWWKynWpicC2zAY5 4ttlEk4D83Pf95VGtsyFoxMy/fPDSkrgwE1Mqdm8dUEdeFQJYGjlYeCJka855IOLL2cT 83FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719874435; x=1720479235; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5eoI38xui1xgULGcdpxHaWYoWkSLh1oKyKiReT5u/ZA=; b=dJd0I875IOJFXNOOzkw44I3onVeZ804DEjhgmHyB+8TuctrQx1QlTW1hyrv5UmwB7z +UgFzh2YqtxonCuVkoIwygl87N6u5aZqc58qZ0OVmPsSeFbVlqlaGRncz+dYLaQ5+3LO Q7e76j74Honms9NQcnqP4OspnugeQ0PTyi061yOxuTrq+nzfhcziXAJyKbcCQb8yy99d DQskciEjjF1lshQk3Mn5QVeSwqaMnfTJKrJUeZMrlD9MnqLxhAc6nm3V/PtIr+0dS0A2 LXDeukmj/grDONHgsXZevGoNKWcJ969jBb5unLLrFkBEBpGDPxVvS0PqWVOkFQWrG7gG amLg== X-Gm-Message-State: AOJu0YzV9YeB1raxQFXaCnFGSMEqVDUK0yffKUgsgfHx9kHVt7swPb0d 0u2fSOpVbrrwr2ZwVvbZ646GeQE+r0qMpazJBTDXZWRtwGs29e9EORhdFi9gXN0SgS3KW7Gg8H2 a X-Google-Smtp-Source: AGHT+IFRUy72xdxjWKAmzQruwNenfjPXl7iP/6DK/3BpFhiQ6LUpvZTePmLOi43cpRCF/aCLDHlHlA== X-Received: by 2002:a05:6214:246c:b0:6b4:fdcd:1604 with SMTP id 6a1803df08f44-6b5b71eba9amr90467216d6.62.1719874435005; Mon, 01 Jul 2024 15:53:55 -0700 (PDT) Received: from n191-036-066.byted.org ([130.44.212.111]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b59e5f34efsm37706356d6.90.2024.07.01.15.53.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 15:53:54 -0700 (PDT) From: zijianzhang@bytedance.com To: netdev@vger.kernel.org Cc: willemdebruijn.kernel@gmail.com, cong.wang@bytedance.com, xiaochun.lu@bytedance.com, Zijian Zhang Subject: [PATCH net 1/2] selftests: fix OOM in msg_zerocopy selftest Date: Mon, 1 Jul 2024 22:53:48 +0000 Message-Id: <20240701225349.3395580-2-zijianzhang@bytedance.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240701225349.3395580-1-zijianzhang@bytedance.com> References: <20240701225349.3395580-1-zijianzhang@bytedance.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Zijian Zhang In selftests/net/msg_zerocopy.c, it has a while loop keeps calling sendmsg on a socket with MSG_ZEROCOPY flag, and it will recv the notifications until the socket is not writable. Typically, it will start the receiving process after around 30+ sendmsgs. However, as the introduction of commit dfa2f0483360 ("tcp: get rid of sysctl_tcp_adv_win_scale"), the sender is always writable and does not get any chance to run recv notifications. The selftest always exits with OUT_OF_MEMORY because the memory used by opt_skb exceeds the net.core.optmem_max. Meanwhile, it could be set to a different value to trigger OOM on older kernels too. Thus, we introduce "cfg_notification_limit" to force sender to receive notifications after some number of sendmsgs. Fixes: 07b65c5b31ce ("test: add msg_zerocopy test") Signed-off-by: Zijian Zhang Signed-off-by: Xiaochun Lu Reviewed-by: Willem de Bruijn --- tools/testing/selftests/net/msg_zerocopy.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/msg_zerocopy.c b/tools/testing/selftests/net/msg_zerocopy.c index bdc03a2097e8..926556febc83 100644 --- a/tools/testing/selftests/net/msg_zerocopy.c +++ b/tools/testing/selftests/net/msg_zerocopy.c @@ -85,6 +85,7 @@ static bool cfg_rx; static int cfg_runtime_ms = 4200; static int cfg_verbose; static int cfg_waittime_ms = 500; +static int cfg_notification_limit = 32; static bool cfg_zerocopy; static socklen_t cfg_alen; @@ -95,6 +96,7 @@ static char payload[IP_MAXPACKET]; static long packets, bytes, completions, expected_completions; static int zerocopied = -1; static uint32_t next_completion; +static uint32_t sends_since_notify; static unsigned long gettimeofday_ms(void) { @@ -208,6 +210,7 @@ static bool do_sendmsg(int fd, struct msghdr *msg, bool do_zerocopy, int domain) error(1, errno, "send"); if (cfg_verbose && ret != len) fprintf(stderr, "send: ret=%u != %u\n", ret, len); + sends_since_notify++; if (len) { packets++; @@ -460,6 +463,7 @@ static bool do_recv_completion(int fd, int domain) static void do_recv_completions(int fd, int domain) { while (do_recv_completion(fd, domain)) {} + sends_since_notify = 0; } /* Wait for all remaining completions on the errqueue */ @@ -549,6 +553,9 @@ static void do_tx(int domain, int type, int protocol) else do_sendmsg(fd, &msg, cfg_zerocopy, domain); + if (cfg_zerocopy && sends_since_notify >= cfg_notification_limit) + do_recv_completions(fd, domain); + while (!do_poll(fd, POLLOUT)) { if (cfg_zerocopy) do_recv_completions(fd, domain); @@ -708,7 +715,7 @@ static void parse_opts(int argc, char **argv) cfg_payload_len = max_payload_len; - while ((c = getopt(argc, argv, "46c:C:D:i:mp:rs:S:t:vz")) != -1) { + while ((c = getopt(argc, argv, "46c:C:D:i:l:mp:rs:S:t:vz")) != -1) { switch (c) { case '4': if (cfg_family != PF_UNSPEC) @@ -736,6 +743,9 @@ static void parse_opts(int argc, char **argv) if (cfg_ifindex == 0) error(1, errno, "invalid iface: %s", optarg); break; + case 'l': + cfg_notification_limit = strtoul(optarg, NULL, 0); + break; case 'm': cfg_cork_mixed = true; break; From patchwork Mon Jul 1 22:53:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijian Zhang X-Patchwork-Id: 13718719 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07CBE171E7C for ; Mon, 1 Jul 2024 22:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719874439; cv=none; b=PRlfL/RasBScr9+qgk3rNxgtX6/PIOllCIL0vCMTNeAcmdMwILscoC+h0k0qSQTx9Kzm1b16AR4SfEt+aJ8DKDuCbZRlQwiRI1ZZ6qOOifOXk2HeFSW7eXNbD73OnPK3bvBi13TWgoc8Iu8RfOAmPQMNcYm7JpkRpQGzeqBmKOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719874439; c=relaxed/simple; bh=Smc0aNxUIdjStnIr7RhacknbiF0AXfn+RG4Z4JpIvXE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uRaGUWQFnUmIs813k4CFHGqfbOlZSwRAkLI34Ko8GzVcMTju0Tp+xFmwEYS/EJeCcLFeh0rjug8M42GDSGhLxqxZ1k8w7tSKqLMo6mtblutV1kZBUpk0BZnrtQfYzR4NSC/zdgklepQ1RKng3nt5JnT3JNZEu2QNBK10GXsDCnc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=iGeZrQXR; arc=none smtp.client-ip=209.85.219.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="iGeZrQXR" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-6b593387daaso35214596d6.1 for ; Mon, 01 Jul 2024 15:53:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1719874436; x=1720479236; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZGrsZnTVUFPPpF/E8fcstNktKQvTmDHTgX9md/Cj9sI=; b=iGeZrQXRxFURLiuFSW4RGwMm2DiFSxUs7n63jJR6Qs8+6YzhcEOIfygUyhsf2olCyb BAxUPrQXYVulhrAwEtJgiZpSWqXPCDh3JRjTxeRKIXnlzmviuNrAbB6BnuqD47W0W7rM bj7UXE7hz0Fp1hzWDgUjbkTdkFDZ8G3ol3bSK31KHQ5b6fDxGm1eEAZHukxjuymhkqOr Lmz1AzZZ27jaJoTQty0pC3elOKkPsBS7GuMe/8hWMVd2raQ1DCDBAruVPacn0yj9wazY 3uQafxcZvlb4Ih2Rc74K/EqbCWFjTYIJH3iIDNeyL9ef22TOeafG4r+xk9orY5Dzsvx2 wpag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719874436; x=1720479236; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZGrsZnTVUFPPpF/E8fcstNktKQvTmDHTgX9md/Cj9sI=; b=eIf6v37NwF5XSswKFxguoDj+ZVIy3Ed9OEqiFJJfqt/qcXqQTag8eLxGy/o7J5oP/8 Do0m2o22c1TuhbR1EEFru5j1EgsyuPcXmu2wjPxGsDa8Ep1wVJt0HPhTcVG+UR+1E6qv dfVWhxAiyRR+qfwlBxwKBHkxs0xwraCXaP4MAHRJOyAaMnsKR3i9imqyQeUu8Pr3m9vD cI5uYQpcHZgQHIl0JKIaqUauLOetbNqkursy/TxVy72HrfHhkcjcUQhNuBWceRmdvtOi AEkKlMTYp5bFxnYdGsSmK7CpfL+dZKBWbn/O90phqA9QGRY6aEAHFEkyR/X8jzAYQn9X AeSw== X-Gm-Message-State: AOJu0Yx0ofUukNpZuXmEsujl8NNkHzdbGjfQ78E+iiPQlQVa4C2vdYTU /THYo3+lo0xMGBFooGpKLq6WEhkHCCxUCkWo0/qFq0GAGWmU0hMXNwsDk1tjnXlDA3hDs4Dh/nl 5 X-Google-Smtp-Source: AGHT+IFMGxWw/WWUSXJJ8Llfjdvh5SvxJrjm7wLTxPwx2Blxw5ir0jidoiY0x1sqbSZTHNJVAm33nw== X-Received: by 2002:ad4:5bea:0:b0:6b5:81ac:6b84 with SMTP id 6a1803df08f44-6b5b6e96bc2mr124719586d6.14.1719874436643; Mon, 01 Jul 2024 15:53:56 -0700 (PDT) Received: from n191-036-066.byted.org ([130.44.212.111]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b59e5f34efsm37706356d6.90.2024.07.01.15.53.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 15:53:56 -0700 (PDT) From: zijianzhang@bytedance.com To: netdev@vger.kernel.org Cc: willemdebruijn.kernel@gmail.com, cong.wang@bytedance.com, xiaochun.lu@bytedance.com, Zijian Zhang Subject: [PATCH net 2/2] selftests: make order checking verbose in msg_zerocopy selftest Date: Mon, 1 Jul 2024 22:53:49 +0000 Message-Id: <20240701225349.3395580-3-zijianzhang@bytedance.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240701225349.3395580-1-zijianzhang@bytedance.com> References: <20240701225349.3395580-1-zijianzhang@bytedance.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Zijian Zhang We find that when lock debugging is on, notifications may not come in order. Thus, we have order checking outputs managed by cfg_verbose, to avoid too many outputs in this case. Fixes: 07b65c5b31ce ("test: add msg_zerocopy test") Signed-off-by: Zijian Zhang Signed-off-by: Xiaochun Lu Reviewed-by: Willem de Bruijn --- tools/testing/selftests/net/msg_zerocopy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/msg_zerocopy.c b/tools/testing/selftests/net/msg_zerocopy.c index 926556febc83..7ea5fb28c93d 100644 --- a/tools/testing/selftests/net/msg_zerocopy.c +++ b/tools/testing/selftests/net/msg_zerocopy.c @@ -438,7 +438,7 @@ static bool do_recv_completion(int fd, int domain) /* Detect notification gaps. These should not happen often, if at all. * Gaps can occur due to drops, reordering and retransmissions. */ - if (lo != next_completion) + if (cfg_verbose && lo != next_completion) fprintf(stderr, "gap: %u..%u does not append to %u\n", lo, hi, next_completion); next_completion = hi + 1;