Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH v1] Netmap pktio fixes #237

Closed
wants to merge 2 commits into from
Closed

[PATCH v1] Netmap pktio fixes #237

wants to merge 2 commits into from

Conversation

MatiasElo
Copy link
Collaborator

No description provided.

Previously the mac addresses of virtual netmap devices would clash if
multiple odp processes were run on the same host.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Checking the minimum frame length is unnecessary as netmap drops truncated
frames internally.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
@muvarov muvarov changed the title Netmap pktio fixes [PATCH v1] Netmap pktio fixes Oct 18, 2017
@@ -388,13 +389,22 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry,

if (pkt_nm->is_virtual) {
static unsigned mac;
uint32_t tid = syscall(SYS_gettid);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use gettid() function? Then you can check for its existence in configure.ac and provide replacement implementation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit from using gettid()? It seems like the only difference is that gettid() cannot fail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was copied from netmap source I think. gittid() will generate warning due to missing glibc wrapper: https://stackoverflow.com/questions/30680550/c-gettid-was-not-declared-in-this-scope Maybe something already changed...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MatiasElo @muvarov Hmm. I thought that there is already a Glibc wrapper. I would prefer this as a separate function, but it is of minor priority then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here for an interesting discussion of why gettid() is not used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lumag we also use SYS_gettid() in shm and timer. I think that is not subject for this PR. Just general clean up.

Copy link
Contributor

@Bill-Fischofer-Linaro Bill-Fischofer-Linaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-by: Bill Fischofer bill.fischofer@linaro.org

@@ -388,13 +389,22 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry,

if (pkt_nm->is_virtual) {
static unsigned mac;
uint32_t tid = syscall(SYS_gettid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here for an interesting discussion of why gettid() is not used.

@@ -388,13 +389,22 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry,

if (pkt_nm->is_virtual) {
static unsigned mac;
uint32_t tid = syscall(SYS_gettid);

if ((int)tid == -1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

man gettid says that it always passes.

kernel code is also:
pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
struct pid_namespace *ns)
{
pid_t nr = 0;

rcu_read_lock();
if (!ns)
	ns = task_active_pid_ns(current);
if (likely(pid_alive(task))) {
	if (type != PIDTYPE_PID)
		task = task->group_leader;
	nr = pid_nr_ns(rcu_dereference(task->pids[type].pid), ns);
}
rcu_read_unlock();

return nr;

}
EXPORT_SYMBOL(__task_pid_nr_ns);

I.e. it will return init process tid 0 in worst case. So this check is not correct and not needed.

It might be needed additional cast:
uint32_t tid = (uint32_t)syscall(SYS_gettid) because of syscall returns pid_t.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syscall() specification still defines -1 as an error return value and we should adhere to the spec regardless of the function implementation which may change.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MatiasElo yes, so this is fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MatiasElo @lumag yep, I forgot that some syscalls might be not implemented on some systems, that also will return error.

@muvarov muvarov self-requested a review October 24, 2017 14:17
@muvarov
Copy link
Contributor

muvarov commented Oct 26, 2017

Merged.

@muvarov muvarov closed this Oct 26, 2017
@MatiasElo MatiasElo deleted the dev/netmap branch October 26, 2017 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants