Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3993154ybf; Tue, 3 Mar 2020 17:26:33 -0800 (PST) X-Google-Smtp-Source: ADFU+vu2NGKkfa4mqtxhT4B3ZKPXq7KH9OEb4ls6EYmgr6B8+wSCvPdHU8IR698+fazrzewlArU1 X-Received: by 2002:a9d:344:: with SMTP id 62mr591696otv.102.1583285193783; Tue, 03 Mar 2020 17:26:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583285193; cv=none; d=google.com; s=arc-20160816; b=zSKVravZj6bAiF4cK026l25cyvFvHIcGmwdbPqfObgHJ41qS5ZCX0K9blvWQL+G4AP I+KIQWWU8aB++2CGY3qviY12HDoLwf/tKi2sCuUrYRUBaAMpjpXQKLAdtLw8BgdAyfVK 3lbb9v5/5koYBrPlyA+lnY/dzu8I4Y1aIxw1ebtmoWdwi/RjzkxZUQmuKcuvf6kzvqCm ybTGfnfdRvCkpnLA8/9MbAE368yRbkAK04/2oS22c6kvh2x8YGes+NfZopJzKKHgL3CG v8DsLjJna2DD0Kmh0POOImIjhvhRGw0XA+pPQ5fZ0x6nRWeRw3ZYhD0JaOr4YW6ks1od kNIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=jrmU0aUpyeiczxdUe8N4p4XFs4SNd8CWnE3coIhgCAs=; b=YkIhQz1H1v7m+rApzJC1fq3ZsRq5Rmaphnpv87wPCTEi8qs44F9jy3Ayt2q7/2o519 BYm+BEI7XXwIJo2bUGtsUxF0ruDlO0D4cJZkc49zNwpx+PX03pU2Q9IiK3QOVHcCx/+L EEH6PrAVMIobAJmaT3rZYJw+zUf8XzBvWcRUVTzF4QLcmOOWjxfhdcW82khn2UL2gsZj p+XfMqL3SsKyPro4AVIQufIr7vnYu6zYjrQLmISMABk9khNYaUpdCwPC65vAx8DpXMOJ ucqzW13w/YbRaJVyTEGwDCvLtM+vmDbE/OJR6BrNElRMgCGcZgJeIZQIr0gfRnBn7FZL nJOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AJEN3Cit; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d85si304686oib.1.2020.03.03.17.26.21; Tue, 03 Mar 2020 17:26:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AJEN3Cit; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387425AbgCDB0I (ORCPT + 99 others); Tue, 3 Mar 2020 20:26:08 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:46742 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727985AbgCDB0I (ORCPT ); Tue, 3 Mar 2020 20:26:08 -0500 Received: by mail-wr1-f67.google.com with SMTP id j7so288105wrp.13 for ; Tue, 03 Mar 2020 17:26:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=jrmU0aUpyeiczxdUe8N4p4XFs4SNd8CWnE3coIhgCAs=; b=AJEN3CitJU/4Z0JTnLw/ey04m43KyIRnf3pgOjFiKT+U6iwItjQytak+e97bRM59WH /0mVfLRbbbWjrEoZdKJ2NorfsJk6k0MxZ+XYdVn3HRYRu8t1OiF+5xjVv5AnRqQTqp7R ztjHJUEORGnsiclnTsjGRYXYq5bRfPhxJq2I0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=jrmU0aUpyeiczxdUe8N4p4XFs4SNd8CWnE3coIhgCAs=; b=UbqzF5W+dE88bX9OIThUa6ahNtbBebRRYDdz1Njc1wlGGRrlMZVZu5wBltGJhJvQ3y VEDObs5IYoW0oaZZePVYS4rp0QcvmlNBrg8lawI2F4XKckvQ/11t5jAK7FYfWKNyCasL ZQLQEzJqDN5J92OpUnz71EEru2rTIaFGg0dmkIVarjp4P6uaQS8kHQJUH/kv1OvttVaw TvOy6hzyuu2J38zzsDpnYHssBWbPFBT5SRl1l/cQ8FYWLKUZ0DVW4bPPa6FXmt0wjtxr RvCQp/tg6cpo69aIruLZqFNSGKVD/6P3+dQFdE0DPTxhIQuiB+7wPH9H4ICjF9MHMj+D 3z+g== X-Gm-Message-State: ANhLgQ3FvRo9l+gNH8Riu4lAzItKwbLjCNywZlF9V6zjTUkMuKRxdsKx saDV5/19SXLAD5EOhQxvIt+DyQ== X-Received: by 2002:a5d:4ec4:: with SMTP id s4mr964900wrv.157.1583285164578; Tue, 03 Mar 2020 17:26:04 -0800 (PST) Received: from chromium.org (77-56-209-237.dclient.hispeed.ch. [77.56.209.237]) by smtp.gmail.com with ESMTPSA id j4sm25875474wrr.0.2020.03.03.17.26.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 17:26:04 -0800 (PST) From: KP Singh X-Google-Original-From: KP Singh Date: Wed, 4 Mar 2020 02:26:02 +0100 To: Alexei Starovoitov Cc: Andrii Nakryiko , open list , bpf , Alexei Starovoitov , Daniel Borkmann , Paul Turner , Florent Revest , Brendan Jackman Subject: Re: [PATCH bpf-next 2/7] bpf: JIT helpers for fmod_ret progs Message-ID: <20200304012602.GB14634@chromium.org> References: <20200303140950.6355-1-kpsingh@chromium.org> <20200303140950.6355-3-kpsingh@chromium.org> <20200303222812.GA5265@chromium.org> <20200303235604.mdlamwx4z2ws3fzy@ast-mbp> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200303235604.mdlamwx4z2ws3fzy@ast-mbp> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03-M?r 15:56, Alexei Starovoitov wrote: > On Tue, Mar 03, 2020 at 11:28:12PM +0100, KP Singh wrote: > > > > +static void align16_branch_target(u8 **pprog) > > > > +{ > > > > + u8 *target, *prog = *pprog; > > > > + > > > > + target = PTR_ALIGN(prog, 16); > > > > + if (target != prog) > > > > + emit_nops(&prog, target - prog); > > > > + if (target != prog) > > > > + pr_err("calcultion error\n"); > > > > > > this wasn't in the original code, do you feel like it's more important > > > to check this and print error? > > > > > > also typo: calculation error, but then it's a bit brief and > > > uninformative message. So I don't know, maybe just drop it? > > > > Ah, good catch! this is deinitely not intended to be here. > > It's a debug artifact and needs to dropped indeed. > > That spurious pr_err() caught my attention as well. > After further analysis there is a bug here. > The function is missing last line: > *pprog = prog; Great catch! Fixed. > Without it the nop insertion is actually not happenning. > Nops are being written, but next insns will overwrite them. > When I noticed it by code review I applied the patches to my tree > and run the tests and, as expected, all tests passed. > The existing test_xdp_veth.sh emits the most amount of unaligned > branches. Since then I've been thinking whether we could add a test > to catch things like this and couldn't come up with a way to test it > without burning a lot of code on it. So let's fix it and move on. > Could you rename this helper? May be emit_align() and pass 16 into it? Seems reasonable. Done. > The code is not branch target specific. It's aligning the start > of the next instruction. > Also could you add a comment to: Done. Sending v2 out. - KP > align16_branch_target(&prog); > for (i = 0; i < fmod_ret->nr_progs; i++) > emit_cond_near_jump(&branches[i], prog, branches[i], > X86_JNE); > kfree(branches); > to say that the loop is updating prior location to jump to aligned > branch target ?