Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4761418imm; Mon, 11 Jun 2018 19:00:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKUvGOoUG5OaqCESqiBpzgGMfijadoz+gbQ4P+GLaYvpOejD6EnHrXaB8sfcL0YGYKcsL76 X-Received: by 2002:a62:6941:: with SMTP id e62-v6mr1688359pfc.56.1528768834743; Mon, 11 Jun 2018 19:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528768834; cv=none; d=google.com; s=arc-20160816; b=dMefGimpc3yNG6w/Vxu6t28dv7diavgb+O7KPzJttu21wrIJBNxHs85dd/lPFcsD2V 1mTf8KDulKYuTPJtAzJoqQogYGqrWgJXGZ6TVolA82RqrFfMTcYcIBpdJ07Ktsh1cECm xuHqYU5OzU+O8NPP7QECj2Zw65pc2V9G2Il2XVcSy0OwCx6m39Jp7rzu/RwNdCi9kPxp VcF/T/Uxj/5nC6SWKv3XPLVvti0sKMTWjiBzcdvkIC3N884tDu8UlvCB+H2KgY3ZCiKx oBQyMAAnmtEKkcKzHdhk+9SvdAJEzgT6laCtpts3x3l/AHJgr4d78nw8QyKyn1ZVIB88 23lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=PiY2sachHv/Xfv4pN/U0cdB/aqZyxZxrWR1MZZwuqsg=; b=Mn2dv5lvI5ob9Pj6/j9LQkzCucR0eqpd5nLtOzPwy6cjtiSffGcxIAWcGHMneq7bPr Htl7RhWhux2xuz9xZAMsiMgKddG/unHH1nXwQgN0Wozt1uF0cVDjL4Qr3dGkXvnnYlM/ hL9PQUuD4804dntoGs++8MSgWCEOXT0Ds64BkmKQ8tnvLxh5IXbifwQZPnd9n2m7Flkt 0oakJ5x46zl5QqNb+NWO72GSF3AQnNnjCZaRBZGF8GpXtyd+yQqtEoOQErqb4mcBhBsA NNQzAfx4Wszk1sPdY/ib8CY7JaxqjAuxpqxwe23qVpkQgdkWGscvbYvftTtZgwkhf62/ jIPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=TQLDkGo8; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v187-v6si35687661pgb.86.2018.06.11.19.00.20; Mon, 11 Jun 2018 19:00:34 -0700 (PDT) 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=@linux-foundation.org header.s=google header.b=TQLDkGo8; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935039AbeFLB7y (ORCPT + 99 others); Mon, 11 Jun 2018 21:59:54 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:39163 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933494AbeFLB7w (ORCPT ); Mon, 11 Jun 2018 21:59:52 -0400 Received: by mail-it0-f66.google.com with SMTP id p185-v6so13471138itp.4; Mon, 11 Jun 2018 18:59:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PiY2sachHv/Xfv4pN/U0cdB/aqZyxZxrWR1MZZwuqsg=; b=TQLDkGo8tzB6iEexk7+EIWzrnEdgMlcLeZlU52CZ1VlsWQOxsaX1SNvf9sakQbb1Gu v/Pf8mtT3xcV9k3DH4Dsuh1FiO5vZkizPvEmZGPAtDRUefunW+6F+BCVtRSXkjtNkB6p bezm9NcE1pWrjqZJnzTfpoSjmi0NPOIWCUB9A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PiY2sachHv/Xfv4pN/U0cdB/aqZyxZxrWR1MZZwuqsg=; b=jAmHr9owNakkn9dewgIscn8fRJE8UkZb8KZuJ6u4FwfRDbzT2+w0MKgSqoR0699qhY SbFwq5vGnc6BYv5JUX8tcQYC4FZfZpHHLwC7RltdD5neczFMRDHiVf+93OCvvSK94bn4 m8gu6oZqQyZ3HYHlR4HuLyJ2YV8spxyIGsQStvRflsbzBYWbAA5mwDgdigzrn0lvrirl 1ct1ZreNPPBheuPqpCxDq1jlqq7a+YvZkk+1y4iby+/wzli3VCDN0zzFF0/rNk1c1KTj 1ehB1VBCxGPS3gJyGf4yG9DoXaxEsfTyzwF9NYli9ZdOBrAsTfKyhShckGuoTA+pEqK0 O5Iw== X-Gm-Message-State: APt69E0sI6qSaYoWGX3HzQu5qIu7VBescBVU+Lw1QnmSeAR2Dimz6rDC tLSrVW41sT1eAbBww1t95xtRkkwF3YQ4lx60ZJoBGaCZ X-Received: by 2002:a24:5b81:: with SMTP id g123-v6mr1289542itb.1.1528768791439; Mon, 11 Jun 2018 18:59:51 -0700 (PDT) MIME-Version: 1.0 References: <20180611192353-mutt-send-email-mst@kernel.org> <20180612042600-mutt-send-email-mst@kernel.org> In-Reply-To: <20180612042600-mutt-send-email-mst@kernel.org> From: Linus Torvalds Date: Mon, 11 Jun 2018 18:59:40 -0700 Message-ID: Subject: Re: [PULL] vhost: cleanups and fixes To: "Michael S. Tsirkin" Cc: KVM list , virtualization , Network Development , Linux Kernel Mailing List , Andrew Morton , Bjorn Andersson , wei.w.wang@intel.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 11, 2018 at 6:36 PM Michael S. Tsirkin wrote: > > Maybe it will help to have GFP_NONE which will make any allocation > fail if attempted. Linus, would this address your comment? It would definitely have helped me initially overlook that call chain. But then when I started looking at the whole dma_map_page() thing, it just raised my hackles again. I would seriously suggest having a much simpler version for the "no allocation, no dma mapping" case, so that it's *obvious* that that never happens. So instead of having virtio_balloon_send_free_pages() call a really generic complex chain of functions that in _some_ cases can do memory allocation, why isn't there a short-circuited "vitruque_add_datum()" that is guaranteed to never do anything like that? Honestly, I look at "add_one_sg()" and it really doesn't make me happy. It looks hacky as hell. If I read the code right, you're really trying to just queue up a simple tuple of , except you encode it as a page pointer in order to play games with the SG logic, and then you hmap that to the ring, except in this case it's all a fake ring that just adds the cpu-physical address instead. And to figuer that out, it's like five layers of indirection through different helper functions that *can* do more generic things but in this case don't. And you do all of this from a core VM callback function with some _really_ core VM locks held. That makes no sense to me. How about this: - get rid of all that code - make the core VM callback save the "these are the free memory regions" in a fixed and limited array. One that DOES JUST THAT. No crazy "SG IO dma-mapping function crap". Just a plain array of a fixed size, pre-allocated for that virtio instance. - make it obvious that what you do in that sequence is ten instructions and no allocations ("Look ma, I wrote a value to an array and incremented the array idex, and I'M DONE") - then in that workqueue entry that you start *anyway*, you empty the array and do all the crazy virtio stuff. In fact, while at it, just simplify the VM interface too. Instead of traversing a random number of buddy lists, just trraverse *one* - the top-level one. Are you seriously ever going to shrink or mark read-only anythin *but* something big enough to be in the maximum order? MAX_ORDER is what, 11? So we're talking 8MB blocks. Do you *really* want the balloon code to work on smaller things, particularly since the whole interface is fundamentally racy and opportunistic to begin with? The whole sequence of events really looks "this is too much complexity, and way too fragile" to me at so many levels. Linus