From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 768D2E732FF for ; Thu, 28 Sep 2023 17:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231520AbjI1RPe (ORCPT ); Thu, 28 Sep 2023 13:15:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231389AbjI1RPb (ORCPT ); Thu, 28 Sep 2023 13:15:31 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C5991A7 for ; Thu, 28 Sep 2023 10:14:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695921279; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IoOMdWsqx13KyfLDmhd8kwn+FZuK3U7Zd1iwFOjjXP0=; b=IqJxie0C2PYnojl6KJqT/K1pUvAykASHFbzvV17yMBYfbc8ZAVvT43wTSaqpgyFOV7G7hL AvhfTfGZN/D0nYZ7ApiF5LERMhHniObphVC/6XDeAzwNV4XQ6oABbRC6yKOEXUk4NSts2w YZ2GrBh10eihKdn/Mb2KbK4rF/QsJ30= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-205-jat8FW8XO5mtTgxvQOb2OQ-1; Thu, 28 Sep 2023 13:14:38 -0400 X-MC-Unique: jat8FW8XO5mtTgxvQOb2OQ-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-30e3ee8a42eso9828804f8f.1 for ; Thu, 28 Sep 2023 10:14:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695921277; x=1696526077; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IoOMdWsqx13KyfLDmhd8kwn+FZuK3U7Zd1iwFOjjXP0=; b=dOFixol+Sa3ZKYxm5WISzHEEy0bRsdFW6uREV6yjPmNGyvHRGukNO1Rxt5nWtMXhYO U+Ub0+4XRpICBy+QkqVumHCCWzwdtYCXuZThhHTK8urCb2uX4WUHX0HSzKcsvRllO/0G TdnCGMQlC1SCXIf+Kf0mJYcT4yx9/wY96YeU9xzanmjGFj3qLlpF2xzzLO2h1oAPLJi9 zZfND+Lzkym4onoTvJsvUnFOnL2qnNKdQ8RLCt0xQ1Qyif+hUZzKV3JH+a1AbM0NEOhb hhY6PGY2MZB/lE7mz16yy1zw89MB4N8sgb6C62panP2KWkJ020DGf58O61gQufxg0IK1 l+Ug== X-Gm-Message-State: AOJu0YxMvTT7Me49Szi1XKzdCgj1A7Jco025zDJYV+mOUS6ahMqTqN1z ki/sbSQdsmGeKEDn7LAWfWbvlnkY6xPlGleGXeu7R0ZqKjcOfX3lYw8mhiNQOVeaQc4q5zXvwyu cOl6d2RGOxWbXcaHEonO6Ru0OwD57hhX3 X-Received: by 2002:a5d:4d45:0:b0:31f:fcee:afcf with SMTP id a5-20020a5d4d45000000b0031ffceeafcfmr1675100wru.71.1695921276844; Thu, 28 Sep 2023 10:14:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGaHAI0Jl7BgDloLvOXP39Cbg4Q6f6RcYSSUyl32ffjmWzsxBgubexMfj/vYKlBpyoT2n5HAQ== X-Received: by 2002:a5d:4d45:0:b0:31f:fcee:afcf with SMTP id a5-20020a5d4d45000000b0031ffceeafcfmr1675065wru.71.1695921276488; Thu, 28 Sep 2023 10:14:36 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:9af8:e5f5:7516:fa89? ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.googlemail.com with ESMTPSA id e21-20020a056402149500b005256d80cdaesm9954826edv.65.2023.09.28.10.14.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Sep 2023 10:14:35 -0700 (PDT) Message-ID: Date: Thu, 28 Sep 2023 19:14:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US To: Sean Christopherson , Isaku Yamahata Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Michael Roth , erdemaktas@google.com, Sagi Shahar , David Matlack , Kai Huang , Zhi Wang , chen.bo@intel.com, linux-coco@lists.linux.dev, Chao Peng , Ackerley Tng , Vishal Annapurve , Yuan Yao , Jarkko Sakkinen , Xu Yilun , Quentin Perret , wei.w.wang@intel.com, Fuad Tabba References: <20230922194029.GA1206715@ls.amr.corp.intel.com> From: Paolo Bonzini Subject: Re: [RFC PATCH v2 0/6] KVM: gmem: Implement test cases for error_remove_page In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/22/23 22:32, Sean Christopherson wrote: > Unless we can't extend fadvise() for some reason, I think we should pursue > FADV_HWPOISION. The enabling should be downright trivial, e.g. just implement > file_operations.fadvise() for guest_memfd, have it handle FADV_HWPOISON, and pass > everything else to generic_fadvise(). > > It'll basically be your ioctl() just without a dedicated ioctl(). > > At the very least, we should run the idea past the fs maintainers. fadvise() is different from madvise() though and not necessarily a great match. Looking at the list of flags in advise(), something like FADV_POPULATE_READ, FADV_PAGEOUT or FADV_COLD would make sense, but I can't really think of any other flag that would be useful in a general case for fadvise. Everything else would have to be very spcific to memfd or guest_memfd. In particular FADV_HWPOISON would not make sense for anything that is not backend by memory. There are some flags that could be useful on gmem file descriptors, such as hypothetically {WIPE,KEEP}ONFORK or SOFT_OFFLINE, but again they're not something that can be applied to fadvise(). So a ioctl implementation does have some advantages after all. I suggest that we reuse MADV_* flags in the ioctl arguments, to leave the door open for future extensions and avoid ioctl proliferation. The ioctl could be implemented by memfd, too, and perhaps even by /dev/zero. Paolo