Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5381072yba; Wed, 8 May 2019 12:20:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqykkGHm5Q2xlUe0x25hBNW8gfAx5mDf4+wKkrbzbeY9J5GzwiCMwx4CgXGCeL+rRDAV2mXN X-Received: by 2002:aa7:99c7:: with SMTP id v7mr51761612pfi.103.1557343227384; Wed, 08 May 2019 12:20:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557343227; cv=none; d=google.com; s=arc-20160816; b=R75BXIWRQxYKp/wKgdNVJKCBmmbR5hNTAWDOY65Upij55j4a9P5rqNqLKkIu9EK/+X ccPutLZ/Wbsw+60Gd1DwJz2qpwMgbH75ep0jVoPOij+JjTrOeVi4Y7uELaHSmRVPk1pb lItUXJsX35tByWnuE1Dng8E/gtEUm/ahZC7aUQKk82x7VrctDV4I1VqKzC9XK4c/aZpU mZjrd+cxZiwg96I6NWiYrg0NP5zAmCINzXxeS9Ykc0p6ThcKzHX8USiS/NtyUfB5aDBK i/bc1JBDxldeZj+llEd85zwhUH0KXvGEecNEoZEVuZCRW0DSvlemzMwhOrmLCKHAeO29 hPOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from:dkim-signature; bh=Xx1nBdwm/fMIaQ+XRMTVvJx4homKW8vOYVCrjJQah8c=; b=cdmHaNCu2JfcIG05PxuwTieL8DUTte9Nc0GIUy0U3EeubwMRDuFdOq7CYP6F1P48XV 0b6bR4zvXI3yTc5WMaegPb5oioVjkiO/53TacyGg+pEMZLwAQX2H7gnO1grmFbVA7JxZ BNJhgJgOKKy5E1WDqi9rMmeW8aJfdod0ZycRoI/oUxM8yCMeenyFCQKUjFK436tuHlPs i403TqNcNxsMRYMDhMaazSJ3i8PAza8XjfrdHgOMdK2//zs7+WExPMQbPppiWDQzCyyu uiiWA9mSs8ow7RETkGJWT3fGuT9pBH1tMUli1DyNB208ukRyT0A0yVsuShCqP1q0BDdm jEFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=u2CwdPBW; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h29si24537798pfd.180.2019.05.08.12.20.03; Wed, 08 May 2019 12:20:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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=@google.com header.s=20161025 header.b=u2CwdPBW; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727414AbfEHTFn (ORCPT + 99 others); Wed, 8 May 2019 15:05:43 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41494 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727328AbfEHTFn (ORCPT ); Wed, 8 May 2019 15:05:43 -0400 Received: by mail-pf1-f195.google.com with SMTP id l132so1478403pfc.8 for ; Wed, 08 May 2019 12:05:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Xx1nBdwm/fMIaQ+XRMTVvJx4homKW8vOYVCrjJQah8c=; b=u2CwdPBWUhvunu491lhDVH7O10yitnzRdNYTDcNKNGaaMw+pYsmkpn0J9MsT99d39Y Q/Wk7PGyXcjoc1tha4UuyE89T0rOnD72kAWNnjYRKkjCa0DELX1ElQVVB5fGF3jmFGkX uLZw9HuRYb+PEeZ/PPFrro1K3Iw9vCnd+ELZuZL2OKCDNAb8u9QKbTbbytR8kbwE4FBI Zo/dlYVRRbaMO0EpBIfmHWL9EiKzdxDQc7t8r9e2EKWR9k2JLXoh6H4LfMbZMUTXsaF+ muQoMtmzSSBP8hE/rlSXFu27Me96rPxVPBbMGgvYpGy27lg+hjZKYMbf9BMngu5WO2ck kXNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Xx1nBdwm/fMIaQ+XRMTVvJx4homKW8vOYVCrjJQah8c=; b=Nq8pn9Iw4+yddN470FOCUAuVocxfhONNzGkR83WQLCPeq3ctxGrBtGjAWP5n75OUft 1SyHXqYdwHQIMYz6zgt999ue4RZs0zH/yeA6yU0ZbRQF8EonARluiFT5tQ0O55AMHFEq WzG4oxPiYQS5C1VYrntIS/Cj00pMdAiMtZ0dBqCS6+VnxTqNhP798zIXLkmMqkiIGDkU zgAVvaCfzQj8LUjYjagBXcijtYiTHH55HZLi2zrh4G8yfkZkhe3jm6e0gmjzMEyA8Z6u dl65H3APNfmeUmS5nAMoqgKvOVWhIo3Rx1IjxQ+LGEIdXmYCfRRI9yPqYffo0+8mCNwP fkTg== X-Gm-Message-State: APjAAAWMo6eGFItl0Gm2ZWd6+114c1UN5cd4OlF/FhDRKyBRRxiOjGxl 35HrN1cm1fu9g6bNUP129E1Csg== X-Received: by 2002:a65:5cc8:: with SMTP id b8mr47363166pgt.36.1557342342253; Wed, 08 May 2019 12:05:42 -0700 (PDT) Received: from jstaron2.mtv.corp.google.com ([2620:15c:202:201:b94f:2527:c39f:ca2d]) by smtp.gmail.com with ESMTPSA id 129sm23470533pff.140.2019.05.08.12.05.40 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 12:05:41 -0700 (PDT) From: =?UTF-8?Q?Jakub_Staro=c5=84?= Subject: Re: [Qemu-devel] [PATCH v7 2/6] virtio-pmem: Add virtio pmem driver To: Pankaj Gupta Cc: linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-acpi@vger.kernel.org, qemu-devel@nongnu.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, jack@suse.cz, mst@redhat.com, jasowang@redhat.com, david@fromorbit.com, lcapitulino@redhat.com, adilger kernel , zwisler@kernel.org, aarcange@redhat.com, dave jiang , darrick wong , vishal l verma , david@redhat.com, willy@infradead.org, hch@infradead.org, jmoyer@redhat.com, nilal@redhat.com, lenb@kernel.org, kilobyte@angband.pl, riel@surriel.com, yuval shaia , stefanha@redhat.com, pbonzini@redhat.com, dan j williams , kwolf@redhat.com, tytso@mit.edu, xiaoguangrong eric , cohuck@redhat.com, rjw@rjwysocki.net, imammedo@redhat.com, smbarber@google.com References: <20190426050039.17460-1-pagupta@redhat.com> <20190426050039.17460-3-pagupta@redhat.com> <3d6479ae-6c39-d614-f1d9-aa1978e2e438@google.com> <1555943483.27247564.1557313967518.JavaMail.zimbra@redhat.com> Message-ID: <3d643ac5-ea1b-efba-9f42-31b2ed3ab5b0@google.com> Date: Wed, 8 May 2019 12:05:39 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1555943483.27247564.1557313967518.JavaMail.zimbra@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 5/8/19 4:12 AM, Pankaj Gupta wrote: > >> >> On 4/25/19 10:00 PM, Pankaj Gupta wrote: >> >>> +void host_ack(struct virtqueue *vq) >>> +{ >>> + unsigned int len; >>> + unsigned long flags; >>> + struct virtio_pmem_request *req, *req_buf; >>> + struct virtio_pmem *vpmem = vq->vdev->priv; >>> + >>> + spin_lock_irqsave(&vpmem->pmem_lock, flags); >>> + while ((req = virtqueue_get_buf(vq, &len)) != NULL) { >>> + req->done = true; >>> + wake_up(&req->host_acked); >>> + >>> + if (!list_empty(&vpmem->req_list)) { >>> + req_buf = list_first_entry(&vpmem->req_list, >>> + struct virtio_pmem_request, list); >>> + list_del(&vpmem->req_list); >> >> Shouldn't it be rather `list_del(vpmem->req_list.next)`? We are trying to >> unlink >> first element of the list and `vpmem->req_list` is just the list head. > > This looks correct. We are not deleting head but first entry in 'req_list' > which is device corresponding list of pending requests. > > Please see below: > > /** > * Retrieve the first list entry for the given list pointer. > * > * Example: > * struct foo *first; > * first = list_first_entry(&bar->list_of_foos, struct foo, list_of_foos); > * > * @param ptr The list head > * @param type Data type of the list element to retrieve > * @param member Member name of the struct list_head field in the list element. > * @return A pointer to the first list element. > */ > #define list_first_entry(ptr, type, member) \ > list_entry((ptr)->next, type, member) Please look at this StackOverflow question: https://stackoverflow.com/questions/19675419/deleting-first-element-of-a-list-h-list Author asks about deleting first element of the queue. In our case (and also in the question's author case), `vpmem->req_list` is not element of any request struct and not an element of the list. It's just a list head storing `next` and `prev` pointers which are then pointing to respectively first and last element of the list. We want to unlink the first element of the list, so we need to pass pointer to the first element of the list to the `list_del` function - that is, the `vpmem->req_list.next`. Thank you, Jakub Staron