Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1467400lqh; Mon, 6 May 2024 08:31:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUjNcAzw9j4AtbRoEEXoml5xZgQuYFN9yNCxNlz2yduoVOFnEWeU58M7sInsk17bjUtwvG+FExu0wDhGaQ3bawregn8FELwNcw8GkeyqQ== X-Google-Smtp-Source: AGHT+IFQ7v5WHFHfikcEYiSD9FK1kQ+/OUfTpNTY4Qccrv3G1QjZ8/GaRaiJULfuYigF3m9SgOdQ X-Received: by 2002:a05:6a20:2d27:b0:1ae:13f0:9bfa with SMTP id g39-20020a056a202d2700b001ae13f09bfamr13004976pzl.44.1715009490422; Mon, 06 May 2024 08:31:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715009490; cv=pass; d=google.com; s=arc-20160816; b=oB02jhR7bYDW4/MUGSJHVcKN6yyNRNROrmib04jd5T163uf8B30dfhC6ELEg8l8cTx IMDeL6icp6b6YwSJl/puKBKOGsGX3MGm5NDlcKIJj43Grl+rN+JxTtkI3RZc4Gvo/Ass uLi2L2r+oks+ff+ZMM8Tcdd0/ffFqcW9oe6/GE0i1Y5mxfB3lQIJxabydwoRHbZJzr2U K7gxs12TPtT/lrA2miyhxeMNHXa3WgTrE1f6AtE5Xh04pHxjD+C4Co14z1RV63GNK7AQ pCTLATMx+PDJAXAp8VWGGkPJcGeDdrROmsUngV2ywnXDkkR+sTjmvnbePXvJE4F9VUjw W1eA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:from:date :dkim-signature; bh=+vbjp8DnEW/5xFyrOmEWjZsrGsFam3906kOD8jwNsEI=; fh=FRU/DuGV4Y9zqf8PtOBioSveXH8vcFueieM2y8x51WQ=; b=PUfWNLCOLeCYxdU/nKjanJCHRSG40N4/Na0/yHhd0HZYyYo5aWy1NdvN/8hQh3UlFb QmAt/K49pyc84YTfcOi4PMBWpgqKRKjKb6UoYBVFw97LsPZgapaPdNkpSPi/sjytmyzB BF0wi+GbBSHJZlUf0dZEdykOmWoIT7Hy2pG4hgytyKoTWGIaD4YVxYsoBW3e5uRmJfdc 55DNppo9bs7KBBIO2iofg+Miojz29bRErjBQ3Z8QEVMvHPfBEg0F70KHoSk8bl3uwWsJ dy0KsQYRZGyGA9s2II28yGyW5MXnNyKnkFfLGd9lKwFdWisV4UkOuEclnvJDTJeVclWf eKEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ssi.bg header.s=ink header.b=EMgTAb78; arc=pass (i=1 spf=pass spfdomain=ssi.bg dkim=pass dkdomain=ssi.bg dmarc=pass fromdomain=ssi.bg); spf=pass (google.com: domain of linux-kernel+bounces-170058-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170058-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ssi.bg Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id ko5-20020a056a00460500b006f47779d427si2679462pfb.43.2024.05.06.08.31.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 08:31:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170058-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ssi.bg header.s=ink header.b=EMgTAb78; arc=pass (i=1 spf=pass spfdomain=ssi.bg dkim=pass dkdomain=ssi.bg dmarc=pass fromdomain=ssi.bg); spf=pass (google.com: domain of linux-kernel+bounces-170058-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170058-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ssi.bg Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6F377B251F4 for ; Mon, 6 May 2024 15:13:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5ABE1553B5; Mon, 6 May 2024 15:10:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ssi.bg header.i=@ssi.bg header.b="EMgTAb78" Received: from mg.ssi.bg (mg.ssi.bg [193.238.174.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F8B0158A2E; Mon, 6 May 2024 15:10:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.238.174.37 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715008225; cv=none; b=rgS7iJcbC+rdvIWBY9P5XQ+hdFijNbSNX/JaBtMsZK351fEJey57KZUWPAclbatThpNv2TMiFP7+PmHU/a7+ZBEwLsyxx0g3//cerVjA7RjU+9yQPKPUnstXPQHKYWBXtwJ5QcIdzBnwQO6v47IGrdw/4c6XQ2Pou5+LIN3CZro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715008225; c=relaxed/simple; bh=o3NLpDCX56xR1aoEOXwK+SJTzlGjlHNBo9hf9W3BY3g=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=nLLvHASsxbmgtds0QRlaFLCoINImfjPNls9uLkemXkC9/fCE/eooPrtc77Js0CRYmNzBoywPVxZu3Xz97QEmK0EfdK8YdIiOLaTVFytCDlX7+Dioq4rzLE1x3jOPWw9QbSfMpRGy3EB8GxY5JLE3PgtZWGJ3+xfHmLCTw4mSPuA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ssi.bg; spf=pass smtp.mailfrom=ssi.bg; dkim=pass (1024-bit key) header.d=ssi.bg header.i=@ssi.bg header.b=EMgTAb78; arc=none smtp.client-ip=193.238.174.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ssi.bg Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ssi.bg Received: from mg.ssi.bg (localhost [127.0.0.1]) by mg.ssi.bg (Proxmox) with ESMTP id 1AF1218691; Mon, 6 May 2024 18:10:12 +0300 (EEST) Received: from ink.ssi.bg (ink.ssi.bg [193.238.174.40]) by mg.ssi.bg (Proxmox) with ESMTPS; Mon, 6 May 2024 18:10:11 +0300 (EEST) Received: from ja.ssi.bg (unknown [213.16.62.126]) by ink.ssi.bg (Postfix) with ESMTPSA id C343C90029B; Mon, 6 May 2024 18:10:07 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ssi.bg; s=ink; t=1715008208; bh=o3NLpDCX56xR1aoEOXwK+SJTzlGjlHNBo9hf9W3BY3g=; h=Date:From:To:cc:Subject:In-Reply-To:References; b=EMgTAb78a/hMj2iIUDd4+im1E+d5ZN5X8lI0GMoAohzK6B79qaH5WBmR+U3B05IIc vLXrsfCJ21hvQZcHLvmGsle1b7rZcYdxflDvdQDj6b512KvS4+2U8ANbXsX+J4/CTu BqYuXdWz8F3/YdOA+EjqMZdlZQWzhzSVMSXwwCkk= Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by ja.ssi.bg (8.17.1/8.17.1) with ESMTP id 446F9xB1093238; Mon, 6 May 2024 18:10:00 +0300 Date: Mon, 6 May 2024 18:09:59 +0300 (EEST) From: Julian Anastasov To: Alexander Mikhalitsyn cc: horms@verge.net.au, netdev@vger.kernel.org, lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal Subject: Re: [PATCH v4 1/2] ipvs: add READ_ONCE barrier for ipvs->sysctl_amemthresh In-Reply-To: <20240506141444.145946-1-aleksandr.mikhalitsyn@canonical.com> Message-ID: <04e3e7bb-7f9f-816d-492f-1f17565719d8@ssi.bg> References: <20240506141444.145946-1-aleksandr.mikhalitsyn@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Hello, On Mon, 6 May 2024, Alexander Mikhalitsyn wrote: > Cc: Julian Anastasov > Cc: Simon Horman > Cc: Pablo Neira Ayuso > Cc: Jozsef Kadlecsik > Cc: Florian Westphal > Suggested-by: Julian Anastasov > Signed-off-by: Alexander Mikhalitsyn Looks good to me for net-next, thanks! Acked-by: Julian Anastasov > --- > net/netfilter/ipvs/ip_vs_ctl.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c > index 50b5dbe40eb8..e122fa367b81 100644 > --- a/net/netfilter/ipvs/ip_vs_ctl.c > +++ b/net/netfilter/ipvs/ip_vs_ctl.c > @@ -94,6 +94,7 @@ static void update_defense_level(struct netns_ipvs *ipvs) > { > struct sysinfo i; > int availmem; > + int amemthresh; > int nomem; > int to_change = -1; > > @@ -105,7 +106,8 @@ static void update_defense_level(struct netns_ipvs *ipvs) > /* si_swapinfo(&i); */ > /* availmem = availmem - (i.totalswap - i.freeswap); */ > > - nomem = (availmem < ipvs->sysctl_amemthresh); > + amemthresh = max(READ_ONCE(ipvs->sysctl_amemthresh), 0); > + nomem = (availmem < amemthresh); > > local_bh_disable(); > > @@ -145,9 +147,8 @@ static void update_defense_level(struct netns_ipvs *ipvs) > break; > case 1: > if (nomem) { > - ipvs->drop_rate = ipvs->drop_counter > - = ipvs->sysctl_amemthresh / > - (ipvs->sysctl_amemthresh-availmem); > + ipvs->drop_counter = amemthresh / (amemthresh - availmem); > + ipvs->drop_rate = ipvs->drop_counter; > ipvs->sysctl_drop_packet = 2; > } else { > ipvs->drop_rate = 0; > @@ -155,9 +156,8 @@ static void update_defense_level(struct netns_ipvs *ipvs) > break; > case 2: > if (nomem) { > - ipvs->drop_rate = ipvs->drop_counter > - = ipvs->sysctl_amemthresh / > - (ipvs->sysctl_amemthresh-availmem); > + ipvs->drop_counter = amemthresh / (amemthresh - availmem); > + ipvs->drop_rate = ipvs->drop_counter; > } else { > ipvs->drop_rate = 0; > ipvs->sysctl_drop_packet = 1; > -- > 2.34.1 Regards -- Julian Anastasov