Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6444152imm; Mon, 23 Jul 2018 18:46:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcdadZtvprzL52e3+EcggQHOkJbM7ULxBLj/a3g9u/kt12C0tFg1f7kfT4jmhjVvgFT8iT/ X-Received: by 2002:a65:4d05:: with SMTP id i5-v6mr14180161pgt.58.1532396794957; Mon, 23 Jul 2018 18:46:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532396794; cv=none; d=google.com; s=arc-20160816; b=f7s77I4kIx1IaeAkQktm3RAMd+PkVZurPobPoyM2XQkzh5GMXq1yBuSuGNnxBnO6uU eQiG9bI7rROOxy4NdlQWHRMM6tvibKnVuBYfwLDm0pg4IbVBJG11cA7tTzcbDuFAnEEf BD0WIkcjqNQMM7g7koZBgjdeV7UMjtYY/z8FSs+nNb4hyhwhnZL098tv7br2ZJHbOGwL iVURvCcG7mxZ4YARk/lbsNlApQa3+6K5H4FihyCgar8zkgUWhJaOs3oHtzoNRrcPC0g8 sG1MTCej3Es9gRd24et65w8VKK4IlofeP3ltNhhxmjaAw9MR2PKQD/TQgIkvNH0gUu5s SUPw== 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:in-reply-to :references:subject:cc:to:mime-version:user-agent:from:date :message-id:arc-authentication-results; bh=HoCLmhZiXnedGgSjU6bXQKfqhFYS/mcHQn5Zew7yPPU=; b=dDbTSy1ddBTaur6dWlHFNCQJfVSiQuScqiBAFhXPpm18ctWaKho55KqJFjDwBlyS4r sMhhMXVhd5kdC99W2a6SFhUwdLsraBQR/Ba4bf5NqfxX4BlZ50YoSBwVx0QQUTd3L5dL angpP7LoaEh4YvkuZUSqws3cx5zSyUrv6GjTXQBkrpmZwqQBjWeR71SohotejAAE4PJT OFCcYA0o11x+UrTuu/5zDy5+ziqTNPJVtOHbnwIaM1rwY+RVuZRC4EaTPHDWrZT5R3gg jSZxvY3Zj1f9rajSnMJYIS6MHUD4LPODydglUdLcq+b0cDoOYSzj/FUHleeJycUC5fL6 vY8A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a194-v6si11249403pfa.18.2018.07.23.18.46.20; Mon, 23 Jul 2018 18:46: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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388359AbeGXCtF (ORCPT + 99 others); Mon, 23 Jul 2018 22:49:05 -0400 Received: from mga07.intel.com ([134.134.136.100]:43787 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388267AbeGXCtF (ORCPT ); Mon, 23 Jul 2018 22:49:05 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jul 2018 18:45:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,394,1526367600"; d="scan'208";a="57321336" Received: from unknown (HELO [10.239.13.97]) ([10.239.13.97]) by fmsmga008.fm.intel.com with ESMTP; 23 Jul 2018 18:45:03 -0700 Message-ID: <5B5685A0.9040005@intel.com> Date: Tue, 24 Jul 2018 09:49:20 +0800 From: Wei Wang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "Michael S. Tsirkin" CC: virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-mm@kvack.org, mhocko@kernel.org, akpm@linux-foundation.org, torvalds@linux-foundation.org, pbonzini@redhat.com, liliang.opensource@gmail.com, yang.zhang.wz@gmail.com, quan.xu0@gmail.com, nilal@redhat.com, riel@redhat.com, peterx@redhat.com Subject: Re: [PATCH v36 2/5] virtio_balloon: replace oom notifier with shrinker References: <1532075585-39067-1-git-send-email-wei.w.wang@intel.com> <1532075585-39067-3-git-send-email-wei.w.wang@intel.com> <20180722174125-mutt-send-email-mst@kernel.org> <5B55AE56.5030404@intel.com> <20180723170826-mutt-send-email-mst@kernel.org> In-Reply-To: <20180723170826-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/23/2018 10:13 PM, Michael S. Tsirkin wrote: >>> vb->vb_dev_info.inode->i_mapping->a_ops = &balloon_aops; >>> #endif >>> + err = virtio_balloon_register_shrinker(vb); >>> + if (err) >>> + goto out_del_vqs; >>> So we can get scans before device is ready. Leak will fail >>> then. Why not register later after device is ready? >> Probably no. >> >> - it would be better not to set device ready when register_shrinker failed. > That's very rare so I won't be too worried. Just a little confused with the point here. "very rare" means it still could happen (even it's a corner case), and if that happens, we got something wrong functionally. So it will be a bug if we change like that, right? Still couldn't understand the reason of changing shrinker_register after device_ready (the original oom notifier was registered before setting device ready too)? (I think the driver won't get shrinker_scan called if device isn't ready because of the reasons below) >> - When the device isn't ready, ballooning won't happen, that is, >> vb->num_pages will be 0, which results in shrinker_count=0 and shrinker_scan >> won't be called. Best, Wei