text:
package com.momia.service.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.stereotype.Service;

import com.momia.entity.User;
import com.momia.service.UserService;

/**
 * 用户
 * @author duohongzhi
 *
 */
@Service
public class UserServiceImpl implements UserService{

	@Resource
	private JdbcTemplate jdbcTemplate;

	public JdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}

	/**
	 * 根据用户id查询用户单个对象
	 */
	public User findUserById(int id) {
		String sql = "select * from t_admin where id = ?";
		final User user = new User();
		final Object[] params = new Object[] {id};
		//调用jdbcTemplate的query方法
		jdbcTemplate.query(sql,params, new RowCallbackHandler(){
			public void processRow(ResultSet rs) throws SQLException {
				//向user对象中添加各个属性值
				userForm(rs, user);
			}
		});
		return user;
	}

	/**
	 * 查询所有用户集合
	 */
	public List<User> findUsers() {
		String sql = "select * from t_admin";
		List<User> ls = new ArrayList<User>();
		List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
		for (int i = 0; i < list.size(); i++) {
			User user = new User();
			user.setId(Integer.parseInt(list.get(i).get("id").toString()));
			user.setUsername(list.get(i).get("username").toString());
			user.setPassword(list.get(i).get("password").toString());
			user.setWechatNo(list.get(i).get("wechatNo").toString());
			user.setAbstracts(list.get(i).get("abstracts").toString());
			user.setAddTime(list.get(i).get("addTime").toString());
			user.setStatus(Integer.parseInt(list.get(i).get("status").toString()));
			user.setUpdateTime(list.get(i).get("updateTime").toString());
			user.setFlag(0);

			ls.add(user);
		}
		return ls;
	}

	/**
	 * 根据用户Id删除用户信息
	 * @param id
	 * @return
	 */
	public int deleteUserById(int id) {
		String sql = "delete from t_admin where id = ?";
		Object[] params = new Object[] {id};
		int flag = jdbcTemplate.update(sql,params);
		return flag;
	}

	/**
	 * 添加用户
	 * @param user
	 * @return
	 */
	public int addUser(User user) {
		String sql = "insert into t_admin (username, password, abstracts, wechatNo, status, addTime, updateTime) values (?, ?, ?, ?, ?, ?, ?)";
		Object[] params = new Object[] {user.getUsername(), user.getPassword(), user.getAbstracts(), user.getWechatNo(), user.getStatus(), user.getAddTime(), user.getUpdateTime()};
		int flag = jdbcTemplate.update(sql,params);
		return flag;
	}

	/**
	 * 使用Id更新用户
	 * @param user
	 * @return
	 */
	public int updateUser(User user) {
		String sql = "update t_admin set username = ?, password = ?, abstracts = ?, wechatNo = ?, status = ?, addTime = ?, updateTime = ? where id = ?";
		//存放SQL语句中的参数
		Object[] params = new Object[] {user.getUsername(), user.getPassword(), user.getAbstracts(), user.getWechatNo(), user.getStatus(), user.getAddTime(), user.getUpdateTime(),user.getId()};
		int flag = jdbcTemplate.update(sql,params);
		return flag;
	}

	/**
	 * 根据用户名和密码查询用户单个对象
	 */
	public User findUserByNameAndPassword(String username, String password) {
		String sql = "select id, username, password, abstracts, wechatNo, status, addTime, updateTime from t_admin where username = ? and password = ?";

		final User user = new User();
		final Object[] params = new Object[] {username,password};
		jdbcTemplate.query(sql,params, new RowCallbackHandler(){
			public void processRow(ResultSet rs) throws SQLException {
				//向user对象中添加各个属性值
				userForm(rs, user);
			}
		});
		return user;
	}

	/**
	 * 根据用户名和密码验证用户信息
	 */
	@SuppressWarnings("deprecation")
	public Boolean isUserByNameAndPassword(String username, String password) {
		boolean istrue = false;
		String sql = "select count(1) as c from t_admin where username = ? and password = ?";
		Object[] params = new Object[] {username,password};
		if(jdbcTemplate.queryForInt(sql, params) > 0){
			istrue = true;
		}
		return istrue;
	}

	public User userForm(ResultSet rs,User user){
		try {
			user.setId(rs.getInt("id"));
			user.setUsername(rs.getString("username"));
			user.setPassword(rs.getString("password"));
			user.setAbstracts(rs.getString("abstracts"));
			user.setWechatNo(rs.getString("wechatNo"));
			user.setStatus(Integer.parseInt(rs.getString("status")));
			user.setAddTime(rs.getString("addTime"));
			user.setUpdateTime(rs.getString("updateTime"));
			user.setFlag(0);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return user;
	}

	public User formUser(HttpServletRequest req,int falg){
		User user = new User();
		if(falg == 0){
			user.setId(Integer.parseInt(req.getParameter("uid")));
		}
		user.setUsername(req.getParameter("username"));
		user.setPassword(req.getParameter("password"));
		user.setAbstracts(req.getParameter("abstracts"));
		user.setWechatNo(req.getParameter("wechatNo"));
		user.setStatus(1);
		user.setAddTime((new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date()));
		user.setUpdateTime((new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date()));

		return user;
	}

	public List<User> findUsers(List<User> users ,int id){
		List<User> ls = new ArrayList<User>();
		if(users.size() > 0){
			for (int i = 0; i < users.size(); i++) {
				User user = users.get(i);
				if(user.getId() == id){
					user.setFlag(1);
				}
				ls.add(user);
			}
		}

		return ls;
	}

}


text:
package jsinterop.base;

import javaemul.internal.annotations.UncheckedCast;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;

/**
 * Abstracts 'any' type in the type system (or '*' in Closure). This is the super type of all types
 * and provides helpers for casting into subtypes that are not otherwise castable (i.e. primitives).
 *
 * <p>See {@link Js#asAny(Object)} to cast an object to {@code Any}.
 */
@JsType(isNative = true, name = "*", namespace = JsPackage.GLOBAL)
public interface Any {

  @JsOverlay
  default JsPropertyMap<Object> asPropertyMap() {
    return Js.asPropertyMap(this);
  }

  @JsOverlay
  default JsArrayLike<Object> asArrayLike() {
    return Js.asArrayLike(this);
  }

  @JsOverlay
  default Any[] asArray() {
    return Js.asArray(this);
  }

  @JsOverlay
  default String asString() {
    return Js.asString(this);
  }

  @JsOverlay
  default boolean asBoolean() {
    return Js.asBoolean(this);
  }

  @JsOverlay
  default double asDouble() {
    return Js.asDouble(this);
  }

  @JsOverlay
  default float asFloat() {
    return Js.asFloat(this);
  }

  @JsOverlay
  default long asLong() {
    return Js.asLong(this);
  }

  @JsOverlay
  default int asInt() {
    return Js.asInt(this);
  }

  @JsOverlay
  default short asShort() {
    return Js.asShort(this);
  }

  @JsOverlay
  default char asChar() {
    return Js.asChar(this);
  }

  @JsOverlay
  default byte asByte() {
    return Js.asByte(this);
  }

  @JsOverlay
  @SuppressWarnings({"TypeParameterUnusedInFormals", "unchecked"})
  default <T> T cast() {
    return (T) this;
  }

  /**
   * Performs unchecked cast to lefthand-side type. You should always prefer regular casting over
   * this (unless you know what you are doing!).
   */
  @JsOverlay
  @UncheckedCast
  @SuppressWarnings({"TypeParameterUnusedInFormals", "unchecked"})
  default <T> T uncheckedCast() {
    return (T) this;
  }
}

redpajama_set_name: RedPajamaGithub


text:
layout: post
title: "Activities in San Diego"
author: ""
categories: weddingsched, logistics
tags: travel
image:
  feature: wed11.jpg
---

Here are some fun activities in the San Diego area if you have some time to spare

# Beaches

There are beautiful public beaches all along the coast in San Diego! This is by far our favorite San Diego activity. We have been learning how to surf near La Jolla Shores. There are more secluded beaches near Torrey Pines state park, which also offers hiking trails. Ocean Beach is further south and has a fun boardwalk.

# La Jolla cove

La Jolla cove is a nice spot to walk around, view sea lions and birds. You can also snorkel and kayak in the cove and its caves (with a guided tour).

# Breweries

San Diego is home to many breweries, such as "The Green Flash" and "Stone". India St offers many small brew-pubs.

# Attractions

* The world-famous San Diego zoo, as seen in the hit film, *Madagascar*, is in San Diego!

* Balboa Park is a beautiful mission style park with museums and cultural events on offer.

# Nearby

* Baja California, Mexico is just south of San Diego. We recommend visiting Ensenada and the nearby "Valle de Guadalupe" if you have a chance.

* Los Angeles is 2 hours north of San Diego.


text:
import React from 'react';
import { Application } from '@spinnaker/core';
import { IFunctionGroup } from 'core/domain';
import { FunctionPod } from './FunctionPod';

export interface IFunctionGroupingsProps {
  app: Application;
  groups: IFunctionGroup[];
}
export class FunctionGroupings extends React.Component<IFunctionGroupingsProps> {
  constructor(props: IFunctionGroupingsProps) {
    super(props);
  }
  public render() {
    return (

        {this.props.groups.map(group => (

            {group.subgroups &&
              group.subgroups.map(subgroup => (
                <FunctionPod
                  key={subgroup.heading}
                  grouping={subgroup}
                  application={this.props.app}
                  parentHeading={group.heading}
                />
              ))}

        ))}

    );
  }
}


text:
// 函数表达式相关
!function(extractTo, appendVariable){

this.FunctionExpression = function(appendRange, appendHoisting, compileBody){
	/**
	 * 函数表达式
	 * @param {Context} context - 语法标签上下文
	 */
	function FunctionExpression(context){
		Expression.call(this, context);
	};
	FunctionExpression = new Rexjs(FunctionExpression, Expression);

	FunctionExpression.props({
		arguments: null,
		body: null,
		/**
		 * 获取当前索引字符串
		 */
		get currentIndexString(){
			return this.variable + ".index.current";
		},
		/**
		 * 提取表达式文本内容
		 * @param {ContentBuilder} contentBuilder - 内容生成器
		 */
		extractTo: function(contentBuilder){
			var defaultArgumentBuilder = new ContentBuilder();

			// 提取函数头部
			this.head.extractTo(contentBuilder);

			// 如果存在星号,说明是生成器
			if(this.star){
				// 如果需要编译
				if(config.es6Base){
					var inner = this.body.inner, collections = inner.collections;

					this.variable = collections.generate();

					// 提取函数名称
					this.name.extractTo(contentBuilder);
					// 提取函数参数
					this.arguments.extractTo(contentBuilder, defaultArgumentBuilder);

					// 追加临时变量名的声明
					contentBuilder.appendString(
						"{var " + collections.rex.toString("", ",", "")
					);

					// 追加生成器内部的变量名声明
					this.ranges.forEach(appendRange, contentBuilder);
					// 追加声明语句的分号
					contentBuilder.appendString(";");
					// 追加变量提升表达式
					this.hoistings.forEach(appendHoisting, contentBuilder);

					// 编译主体代码
					compileBody(this, defaultArgumentBuilder, inner, contentBuilder);
					return;
				}

				// 追加星号上下文
				contentBuilder.appendContext(this.star);
			}

			// 提取函数名称
			this.name.extractTo(contentBuilder);
			// 提取函数参数
			this.arguments.extractTo(contentBuilder, defaultArgumentBuilder);
			// 提取函数主体
			this.body.extractTo(contentBuilder, defaultArgumentBuilder);
		},
		head: null,
		hoistings: null,
		index: 0,
		name: new DefaultExpression(),
		/**
		 * 设置下一个索引
		 * @param {ContentBuilder} contentBuilder - 内容生成器
		 */
		nextIndex: function(contentBuilder){
			return ++this.index;
		},
		ranges: null,
		star: null,
		/**
		 * 转化为生成器
		 * @param {Context} star - 生成器星号上下文
		 */
		toGenerator: function(star){
			this.star = star;
			this.ranges = [];
			this.hoistings = [];
		},
		variable: ""
	});

	return FunctionExpression;
}(
	// appendRange
	function(range){
		range.forEach(appendVariable, this);
	},
	// appendHoisting
	function(hoisting){
		hoisting.extractTo(this);
	},
	// compileBody
	function(expression, defaultArgumentBuilder, inner, contentBuilder){
		var variable = expression.variable, currentIndexString = expression.currentIndexString;

		// 追加迭代器代码
		contentBuilder.appendString(
			defaultArgumentBuilder.result +
			variable +
			"= new Rexjs.FunctionIterator(function(){for(;;){switch(" +
			currentIndexString +
			"){case " +
			expression.index +
			":"
		);

		// 提取函数主体
		extractTo.call(inner, contentBuilder);

		// 追加迭代器结束代码及生成器代码
		contentBuilder.appendString(
			"default:" +
			currentIndexString +
			"=NaN;return void 0;}}},this,arguments);return new Rexjs.Generator(" +
			variable +
			");}"
		);
	}
);

this.FunctionTag = function(FunctionExpression){
	/**
	 * 函数标签
	 * @param {Number} _type - 标签类型
	 */
	function FunctionTag(_type){
		SyntaxTag.call(this, _type);
	};
	FunctionTag = new Rexjs(FunctionTag, SyntaxTag);

	FunctionTag.props({
		$class: CLASS_EXPRESSION,
		regexp: /function/,
		/**
		 * 获取此标签接下来所需匹配的标签列表
		 * @param {TagsMap} tagsMap - 标签集合映射
		 */
		require: function(tagsMap){
			return tagsMap.functionContextTags;
		},
		/**
		 * 标签访问器
		 * @param {SyntaxParser} parser - 语法解析器
		 * @param {Context} context - 标签上下文
		 * @param {Statement} statement - 当前语句
		 * @param {Statements} statements - 当前语句块
		 */
		visitor: function(parser, context, statement, statements){
			// 设置当前表达式
			(
				statement.expression = new FunctionExpression(context)
			)
			// 设置函数表达式头部
			.head = new Expression(context);
		}
	});

	return FunctionTag;
}(
	this.FunctionExpression
);

this.StarTag = function(){
	/**
	 * 星号标签
	 * @param {Number} _type - 标签类型
	 */
	function StarTag(_type){
		SyntaxTag.call(this, _type);
	};
	StarTag = new Rexjs(StarTag, SyntaxTag);

	StarTag.props({
		regexp: /\*/,
		/**
		 * 获取此标签接下来所需匹配的标签列表
		 * @param {TagsMap} tagsMap - 标签集合映射
		 */
		require: function(tagsMap){
			return tagsMap.starContextTags;
		},
		/**
		 * 标签访问器
		 * @param {SyntaxParser} parser - 语法解析器
		 * @param {Context} context - 标签上下文
		 * @param {Statement} statement - 当前语句
		 * @param {Statements} statements - 当前语句块
		 */
		visitor: function(parser, context, statement, statements){
			// 将函数表达式转化为生成器
			statement.expression.toGenerator(context);
		}
	});

	return StarTag;
}();

this.FunctionNameTag = function(VariableDeclarationTag, FunctionDeclarationExpression){
	/**
	 * 函数名标签
	 * @param {Number} _type - 标签类型
	 */
	function FunctionNameTag(_type){
		VariableDeclarationTag.call(this, _type);
	};
	FunctionNameTag = new Rexjs(FunctionNameTag, VariableDeclarationTag);

	FunctionNameTag.props({
		/**
		 * 提取文本内容
		 * @param {ContentBuilder} contentBuilder - 内容生成器
		 * @param {String} content - 标签内容
		 */
		extractTo: function(contentBuilder, content){
			// 追加空格
			contentBuilder.appendSpace();
			// 追加标签内容
			contentBuilder.appendString(content);
		},
		/**
		 * 获取此标签接下来所需匹配的标签列表
		 * @param {TagsMap} tagsMap - 标签集合映射
		 */
		require: function(tagsMap){
			return tagsMap.functionArgumentTags;
		},
		/**
		 * 标签访问器
		 * @param {SyntaxParser} parser - 语法解析器
		 * @param {Context} context - 标签上下文
		 * @param {Statement} statement - 当前语句
		 * @param {Statements} statements - 当前语句块
		 */
		visitor: function(parser, context, statement, statements){
			// 设置函数表达式的名称
			statement.expression.name = new Expression(context);
		}
	});

	return FunctionNameTag;
}(
	this.VariableDeclarationTag,
	this.FunctionDeclarationExpression
);

}.call(
	this,
	Rexjs.Statements.prototype.extractTo,
	// appendVariable
	function(variable, contentBuilder){
		contentBuilder.appendString("," + variable);
	}
);


text:
package me.nikosgram.oglofus.configuration;

public interface StorageDriver< T >
{
    /**
     * Create the configuration file and the parent directories.
     *
     * @return true if the configuration file exists!
     */
    boolean create();

    /**
     * Write the object to the file.
     */
    void save();

    /**
     * Reading and parse the configuration file in a stream and
     * produce the corresponding Java object.
     */
    void load();
}


text:
class HomeController < ApplicationController
  layout 'frontend'

  STATUS = Hash.new('warning')
  STATUS[true] = 'ok'
  STATUS[false] = 'error'

  OS_VERSION = "Description:\tUbuntu 12.04"
  PG_VERSION = 'PostgreSQL 9.3'
  POSTGIS_VERSION = '2.1'
  CDB_VALID_VERSION = '0.9'
  CDB_LATEST_VERSION = '0.9.3'
  REDIS_VERSION = '3.0'
  RUBY_BIN_VERSION = 'ruby 1.9.3'
  NODE_VERSION = 'v0.10'
  GEOS_VERSION = '3.4.2'
  GDAL_VERSION = '1.11'

  WINDSHAFT_VALID_VERSION = '2.12'
  WINDSHAFT_LATEST_VERSION = '2.12.1'
  RUN_WINDSHAFT_INSTRUCTIONS = 'Run Windshaft: cd /Windshaft-cartodb && node app.js development'
  SQL_API_VALID_VERSION = '1.24'
  SQL_API_LATEST_VERSION = '1.24.0'
  RUN_SQL_API_INSTRUCTIONS = 'Run SQL API: cd /CartoDB-SQL-API; node app.js development'
  RUN_RESQUE_INSTRUCTIONS =  'Run Resque: bundle exec script/resque'

  skip_before_filter :browser_is_html5_compliant?, :only => :app_status
  # Don't force org urls
  skip_before_filter :ensure_org_url_if_org_user

  def app_status
    return head(503) if Cartodb.config[:disable_file] && File.exists?(File.expand_path(Cartodb.config[:disable_file]))
    db_ok    = check_db
    redis_ok = check_redis
    api_ok   = true
    head (db_ok && redis_ok && api_ok) ? 200 : 500
  rescue => e
    CartoDB::Logger.info 'status method failed', e.inspect
    head 500
  end

  def app_diagnosis
    return head(400) if Cartodb.config[:cartodb_com_hosted] == false

    @diagnosis = [
      diagnosis_output('Configuration') { configuration_diagnosis() },
      diagnosis_output('Operating System') { single_line_command_version_diagnosis('lsb_release -a', OS_VERSION, 1) },
      diagnosis_output('Ruby') { single_line_command_version_diagnosis('ruby --version', RUBY_BIN_VERSION) },
      diagnosis_output('Node') { single_line_command_version_diagnosis('node --version', NODE_VERSION) },
      diagnosis_output('PostgreSQL') { pg_diagnosis },
      diagnosis_output('PostGIS') { extension_diagnosis('postgis', POSTGIS_VERSION) },
      diagnosis_output('CartoDB extension') { extension_diagnosis('cartodb', CDB_VALID_VERSION, CDB_LATEST_VERSION) },
      diagnosis_output('Database connection') { db_diagnosis },
      diagnosis_output('Redis') { redis_diagnosis },
      diagnosis_output('Redis connection') { redis_connection_diagnosis },
      diagnosis_output('Windshaft', RUN_WINDSHAFT_INSTRUCTIONS) { windshaft_diagnosis(WINDSHAFT_VALID_VERSION, WINDSHAFT_LATEST_VERSION) },
      diagnosis_output('SQL API', RUN_SQL_API_INSTRUCTIONS) { sql_api_diagnosis(SQL_API_VALID_VERSION, SQL_API_LATEST_VERSION) },
      diagnosis_output('Resque') { resque_diagnosis(RUN_RESQUE_INSTRUCTIONS) },
      diagnosis_output('GEOS') { single_line_command_version_diagnosis('geos-config --version', GEOS_VERSION) },
      diagnosis_output('GDAL') { single_line_command_version_diagnosis('gdal-config --version', GDAL_VERSION) },
    ]
  end

  private

  def configuration_diagnosis
    ['', [
      "Environment: #{environment}",
      "Subdomainless URLs: #{Cartodb.config[:subdomainless_urls]}"
    ]]
  end

  def environment
    Rails.env
  end

  def pg_diagnosis
    version_diagnosis(PG_VERSION) {
      version = Rails::Sequel.connection.fetch('select version()').first.values[0]
      [version, [version]]
    }
  end

  def db_diagnosis
    [STATUS[check_db], []]
  end

  def redis_diagnosis
    version_diagnosis(REDIS_VERSION) {
      version = $tables_metadata.info['redis_version']
      [version, [version]]
    }
  end

  def redis_connection_diagnosis
    [STATUS[check_redis], []]
  end

  def windshaft_diagnosis(supported_version, latest_version)
    config = Cartodb.config[:tiler]
    url_config_key = 'internal'
    endpoint_prefix = ""
    version_key = 'windshaft_cartodb'

    api_service_diagnosis(config, url_config_key, supported_version, latest_version, endpoint_prefix, version_key)
  end

  def sql_api_diagnosis(supported_version, latest_version)
    config = Cartodb.config[:sql_api]
    url_config_key = 'private'
    endpoint_prefix = "api/v1/"
    version_key = 'cartodb_sql_api'

    api_service_diagnosis(config, url_config_key, supported_version, latest_version, endpoint_prefix, version_key)
  end

  def api_service_diagnosis(config, url_config_key, supported_version, latest_version, endpoint_prefix, version_key)
    service_url = configuration_url(config[url_config_key])
    info = safe_json_get("#{service_url}/#{endpoint_prefix}version")

    version = info[version_key]
    messages = ["Service url: #{service_url}"]
    messages << "Full config: #{config}"
    messages.concat info.to_a.map {|s, v| "#{s}: #{v}"}
    valid = valid?(supported_version, latest_version, version)

    if valid != false
      messages << "Currently we support #{supported_version}. Latest: #{latest_version}" unless valid

      health = safe_json_get("#{service_url}/#{endpoint_prefix}health")
      unless health['enabled'] == true
        health['instructions'] = "Enable health checking at config/environments/#{environment}.js"
      end
      health_ok = health['ok'] == true
      messages.concat(health.reject { |k, v| k == 'result' }.to_a.map {|s, v| "Health #{s}: #{v}"})
    end

    [STATUS[response.response_code == 200 && valid && health_ok], messages]
  end

  # true: latest
  # nil: supported
  # false: not supported
  def valid?(supported_version, latest_version, version)
    if (version =~ /\A#{latest_version}/ ? true : nil)
      true
    else
      version =~ /\A#{supported_version}/ ? nil : false
    end
  end

  def resque_diagnosis(help)
    Open3.popen3('ps xah | grep "[s]cript/resque"') do |stdin, stdout, stderr, process|
      output = stdout.read
      status = output != nil && output != ''
      messages = output.split("\n")
      [STATUS[status], messages.append(status ? ("Running pids: #{running_import_ids}") : help)]
    end
  end

  def running_import_ids
    Resque::Worker.all.map do |worker|
      next unless worker.job['queue'] == 'imports'
      worker.job['payload']['args'].first['job_id'] rescue nil
    end.compact
  end

  def check_db
    Rails::Sequel.connection.select('OK').first.values.include?('OK')
  end

  def check_redis
    $tables_metadata.dbsize != nil
  end

  def http_client
    @http_client ||= Carto::Http::Client.get('diagnosis')
  end

  def diagnosis_output(title, help = nil)
    [title, safe_diagnosis(help) { yield } ].flatten(1)
  end

  def safe_diagnosis(help = nil)
    yield
  rescue => e
    [ STATUS[false], [ help, e.to_s ].compact ]
  end

  def extension_diagnosis(extension, supported_version, latest_version = nil)
    version = Rails::Sequel.connection.fetch("select default_version from pg_available_extensions where name = '#{extension}'").first.values[0]

    status_and_messages(version, [], supported_version, latest_version)
  end

  def version_diagnosis(supported_version, latest_version = nil)
    version_and_messages = yield
    version = version_and_messages[0]
    messages = version_and_messages[1]
    status_and_messages(version, messages, supported_version, latest_version)
  end

  def status_and_messages(version, messages, supported_version, latest_version)
    valid = version =~ /\A#{supported_version}/ ? true : false
    messages = ["Installed version: #{version}"]
    messages << "Current supported version: #{supported_version}.#{ latest_version.nil? ? '' : "Latest version: #{latest_version}" }" unless valid
    if latest_version && valid
      latest = version =~ /\A#{latest_version}/ ? true : false
      messages << "Latest version: #{latest_version}" unless latest
      [STATUS[latest || 'supported'], messages]
    else
      [STATUS[valid], messages]
    end
  end

  def single_line_command_version_diagnosis(command, supported_version, line_index = 0, latest_version = nil)
    version_diagnosis(supported_version, latest_version) {
      stdin, stdout, stderr, process = Open3.popen3(command)
      output = stdout.read.split("\n")
      if latest_version.nil?
        [output[line_index], output]
      end
    }
  end

  def configuration_url(conf)
    "#{conf['protocol']}://#{conf['domain']}:#{conf['port']}"
  end

  def safe_json_get(url)
    JSON.parse(http_client.get(url).body)
  rescue => e
    { 'error fetching info' => e.message }
  end

end


text:
package com.ramotion.foldingcell.animations;

import android.view.animation.Animation;

/**
 * Just sugar for code clean
 */
public abstract class AnimationEndListener implements Animation.AnimationListener {

    @Override
    public void onAnimationStart(Animation animation) {
        // do nothing
    }

    @Override
    public void onAnimationRepeat(Animation animation) {
        // do nothing
    }

}


text:
class RakeCompletion < Formula
  desc "Bash completion for Rake"
  homepage "https://github.com/JoeNyland/rake-completion"
  url "https://github.com/JoeNyland/rake-completion/archive/v1.0.1.tar.gz"
  sha256 "085801e62cb240311d77885778a603f649b3fd5d85ee279691d1d00bc060bba6"
  license "MIT"

  bottle :unneeded

  def install
    bash_completion.install "rake.sh" => "rake"
  end

  test do
    assert_match "-F _rakecomplete",
      shell_output("source #{bash_completion}/rake && complete -p rake")
  end
end


text:
namespace chrono {
namespace vehicle {

/// @addtogroup vehicle_wheeled_tire
/// @{

/// Pacejka tire constructed with data from file (JSON format).
class CH_VEHICLE_API PacejkaTire : public ChPacejkaTire {
  public:
    PacejkaTire(const std::string& filename);
    PacejkaTire(const rapidjson::Document& d);
    ~PacejkaTire() {}

    virtual double GetMass() const override { return m_mass; }
    virtual ChVector<> GetInertia() const override { return m_inertia; }

    virtual void AddVisualizationAssets(VisualizationType vis) override;
    virtual void RemoveVisualizationAssets() override final;

  private:
    virtual void Create(const rapidjson::Document& d) override;

    double m_mass;
    ChVector<> m_inertia;

    bool m_has_mesh;
    std::string m_meshFile_left;
    std::string m_meshFile_right;
    std::shared_ptr<ChTriangleMeshShape> m_trimesh_shape;
};

/// @} vehicle_wheeled_tire

}  // end namespace vehicle
}  // end namespace chrono

#endif


text:
#include "instr_stack_push.h"

#include <vector>

const std::vector<c64::Instr>& c64::InstrStackPush::validInstructions() const
{
  static const std::vector<c64::Instr> validInstructions{Instr::PHP, Instr::PHA};
  return validInstructions;
}

void c64::InstrStackPush::doExecSingle()
{
  switch (cycles_)
  {
    case 0:
      // Fetch op-code
      return;
    case 1:
      // opcode discarded
      cpu_->incrementPC();
      accessMode_ = AccessMode::write;
      return;
    case 2:
      // Write internal register
      // (an address needs to be passed to satisfy PMF type signature)
      ((*cpu_).*machineInstr_)(memmap::immediateAddr /* unused */);
      end_ = true;
  }
}

void c64::InstrStackPush::doReset()
{
}

unsigned short c64::InstrStackPush::length() const noexcept
{
  return 1;
}

//
// ################################### Tests #################################

#include <doctest.h>

TEST_CASE("InstrStackPush")
{
  c64::Memory memory;
  c64::CPU cpu{memory};

  DOCTEST_SUBCASE("Construction")
  {
    c64::InstrStackPush instr{c64::Instr::PHA, &c64::CPU::pha};
    instr.reset(&cpu);
    REQUIRE(instr.cycles() == 0);
    REQUIRE(!instr.end());
  }

  DOCTEST_SUBCASE("pha_overflow")
  {
    c64::InstrStackPush instr{c64::Instr::PHA, &c64::CPU::pha};
    instr.reset(&cpu);

    cpu.a(0x03);
    cpu.pc(0xc001);
    REQUIRE(cpu.sp() == 0xff);

    REQUIRE(instr.accessMode() == c64::AccessMode::read);
    instr.execSingle();
    REQUIRE(cpu.pc() == 0xc001);

    REQUIRE(instr.accessMode() == c64::AccessMode::read);
    instr.execSingle();
    REQUIRE(cpu.pc() == 0xc002);

    REQUIRE(cpu.sp() == 0xff);
    REQUIRE(instr.accessMode() == c64::AccessMode::write);
    instr.execSingle();
    REQUIRE(cpu.sp() == 0xfe);
    REQUIRE(instr.end());
    REQUIRE(instr.cycles() == 3);
    REQUIRE(cpu.pc() == 0xc002);
    REQUIRE(cpu.peekStack(0xff) == 0x03);
  }

  // overflow situation covered by tests in cpu_stack_instr.cpp
}


text:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Camera_Limits : MonoBehaviour {
    [HideInInspector]
    public float colDepth = 4f;
    public float zPosition = 0f;
    private Vector2 screenSize;
    private Transform topCollider;
    private Transform bottomCollider;
    private Transform leftCollider;
    private Transform rightCollider;
    private Vector3 cameraPos;
    // Use this for initialization
    void Start()
    {
        //Generate our empty objects
        topCollider = new GameObject().transform;
        bottomCollider = new GameObject().transform;
        rightCollider = new GameObject().transform;
        leftCollider = new GameObject().transform;

        //Name our objects
        topCollider.name = "TopCollider";
        bottomCollider.name = "BottomCollider";
        rightCollider.name = "RightCollider";
        leftCollider.name = "LeftCollider";

        //Add the colliders
        topCollider.gameObject.AddComponent<BoxCollider2D>();
        bottomCollider.gameObject.AddComponent<BoxCollider2D>();
        rightCollider.gameObject.AddComponent<BoxCollider2D>();
        leftCollider.gameObject.AddComponent<BoxCollider2D>();

        //Make them the child of whatever object this script is on, preferably on the Camera so the objects move with the camera without extra scripting
        topCollider.parent = transform;
        bottomCollider.parent = transform;
        rightCollider.parent = transform;
        leftCollider.parent = transform;

        //Generate world space point information for position and scale calculations
        cameraPos = Camera.main.transform.position;
        screenSize.x = Vector2.Distance(Camera.main.ScreenToWorldPoint(new Vector2(0, 0)), Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, 0))) * 0.5f;
        screenSize.y = Vector2.Distance(Camera.main.ScreenToWorldPoint(new Vector2(0, 0)), Camera.main.ScreenToWorldPoint(new Vector2(0, Screen.height))) * 0.5f;

        //Change our scale and positions to match the edges of the screen...
        rightCollider.localScale = new Vector3(colDepth, screenSize.y * 2, colDepth);
        rightCollider.position = new Vector3(cameraPos.x + screenSize.x + (rightCollider.localScale.x * 0.5f), cameraPos.y, zPosition);
        leftCollider.localScale = new Vector3(colDepth, screenSize.y * 2, colDepth);
        leftCollider.position = new Vector3(cameraPos.x - screenSize.x - (leftCollider.localScale.x * 0.5f), cameraPos.y, zPosition);
        topCollider.localScale = new Vector3(screenSize.x * 2, colDepth, colDepth);
        topCollider.position = new Vector3(cameraPos.x, cameraPos.y + screenSize.y + (topCollider.localScale.y * 0.5f), zPosition);
        bottomCollider.localScale = new Vector3(screenSize.x * 2, colDepth, colDepth);
        bottomCollider.position = new Vector3(cameraPos.x, cameraPos.y - screenSize.y - (bottomCollider.localScale.y * 0.5f), zPosition);
    }
  }


text: require_relative 'throttle-queue/single-process'


text:
function prereqs() {
  echo "${FUNCNAME[0]}: Install prerequisites"
  sudo apt-get install -y virtinst qemu-kvm libguestfs-tools virtualenv git python-pip
  echo "${FUNCNAME[0]}: Setup $USER for kvm use"
  # Per http://libguestfs.org/guestfs-faq.1.html
  # workaround for virt-customize warning: libguestfs: warning: current user is not a member of the KVM group (group ID 121). This user cannot access /dev/kvm, so libguestfs may run very slowly. It is recommended that you 'chmod 0666 /dev/kvm' or add the current user to the KVM group (you might need to log out and log in again).
  # Also see: https://help.ubuntu.com/community/KVM/Installation
  # also to avoid permission denied errors in guestfish, from http://manpages.ubuntu.com/manpages/zesty/man1/guestfs-faq.1.html
  sudo usermod -a -G kvm $USER
  sudo chmod 0644 /boot/vmlinuz*
  echo "${FUNCNAME[0]}: Clone repo"
}

function setup () {
  rm -r ~/cloudify
  mkdir -p ~/cloudify
  cd ~/cloudify
  echo "${FUNCNAME[0]}: Setup Cloudify-CLI"
  # Per http://docs.getcloudify.org/4.1.0/installation/bootstrapping/#installing-cloudify-manager-in-an-offline-environment
  wget -q http://repository.cloudifysource.org/cloudify/17.9.21/community-release/cloudify-cli-community-17.9.21.deb
  # Installs into /opt/cfy/
  sudo dpkg -i cloudify-cli-community-17.9.21.deb
  export MANAGER_BLUEPRINTS_DIR=/opt/cfy/cloudify-manager-blueprints
  virtualenv ~/cloudify/env
  source ~/cloudify/env/bin/activate

  echo "${FUNCNAME[0]}: Setup Cloudify-Manager"
  # to start over
  # sudo virsh destroy cloudify-manager; sudo virsh undefine cloudify-manager
  wget -q http://repository.cloudifysource.org/cloudify/17.9.21/community-release/cloudify-manager-community-17.9.21.qcow2
  # nohup and redirection of output is a workaround for some issue with virt-install never outputting anything beyond "Creadint domain..." and thus not allowing the script to continue.
  nohup virt-install --connect qemu:///system --virt-type kvm --name cloudify-manager --vcpus 4 --memory 16192 --disk cloudify-manager-community-17.9.21.qcow2 --import --network network=default --os-type=linux --os-variant=rhel7 > /dev/null 2>&1 &

  VM_IP=""
  n=0
  while [[ "x$VM_IP" == "x" ]]; do
    echo "${FUNCNAME[0]}: $n minutes so far; waiting 60 seconds for cloudify-manager IP to be assigned"
    sleep 60
    ((n++))
    VM_MAC=$(virsh domiflist cloudify-manager | grep default | grep -Eo "[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+:[0-9a-f\]+")
    VM_IP=$(/usr/sbin/arp -e | grep ${VM_MAC} | awk {'print $1'})
  done
  echo "${FUNCNAME[0]}: cloudify-manager IP=$VM_IP"
  while ! cfy profiles use $VM_IP -u admin -p admin -t default_tenant ; do
    echo "${FUNCNAME[0]}: waiting 60 seconds for cloudify-manager API to be active"
    sleep 60
  done
  cfy status

  echo "${FUNCNAME[0]}: Install Cloudify Kubernetes Plugin"
  # Per http://docs.getcloudify.org/4.1.0/plugins/container-support/
  # Per https://github.com/cloudify-incubator/cloudify-kubernetes-plugin
  pip install kubernetes wagon
  # From https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/releases
  wget -q https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/releases/download/1.2.1/cloudify_kubernetes_plugin-1.2.1-py27-none-linux_x86_64-centos-Core.wgn
  # For Cloudify-CLI per http://docs.getcloudify.org/4.1.0/plugins/using-plugins/
  wagon install cloudify_kubernetes_plugin-1.2.1-py27-none-linux_x86_64-centos-Core.wgn
  # For Cloudify-Manager per https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/blob/master/examples/persistent-volumes-blueprint.yaml
  cfy plugins upload cloudify_kubernetes_plugin-1.2.1-py27-none-linux_x86_64-centos-Core.wgn

  mkdir ~/cloudify/blueprints

  echo "${FUNCNAME[0]}: Create secrets for kubernetes as referenced in blueprints"
  cfy secrets create -s $(grep server ~/.kube/config | awk -F '/' '{print $3}' | awk -F ':' '{print $1}') kubernetes_master_ip
  cfy secrets create -s $(grep server ~/.kube/config | awk -F '/' '{print $3}' | awk -F ':' '{print $2}') kubernetes_master_port
  cfy secrets create -s $(grep 'certificate-authority-data: ' ~/.kube/config | awk -F ' ' '{print $2}') kubernetes_certificate_authority_data
  cfy secrets create -s $(grep 'client-certificate-data: ' ~/.kube/config | awk -F ' ' '{print $2}') kubernetes-admin_client_certificate_data
  cfy secrets create -s $(grep 'client-key-data: ' ~/.kube/config | awk -F ' ' '{print $2}') kubernetes-admin_client_key_data
  cfy secrets list

  echo "${FUNCNAME[0]}: Cloudify CLI config is at ~/.cloudify/config.yaml"
  echo "${FUNCNAME[0]}: Cloudify CLI log is at ~/.cloudify/logs/cli.log"
}

function demo() {
  # Per http://docs.getcloudify.org/4.1.0/plugins/container-support/
  # Per https://github.com/cloudify-incubator/cloudify-kubernetes-plugin
  # Also per guidance at https://github.com/cloudify-incubator/cloudify-kubernetes-plugin/issues/18
  mkdir -p ~/cloudify/blueprints/k8s-hello-world
  cp ~/nancy/cloudify/blueprints/k8s-hello-world.yaml ~/cloudify/blueprints/k8s-hello-world/blueprint.yaml
#  echo "master-ip: $(grep server ~/.kube/config | awk -F '/' '{print $3}' | awk -F ':' '{print $1}')" >~/cloudify/blueprints/k8s-hello-world/inputs.yaml
#  echo "master-port: $(grep server ~/.kube/config | awk -F '/' '{print $3}' | awk -F ':' '{print $2}')" >>~/cloudify/blueprints/k8s-hello-world/inputs.yaml
#  echo "file_content:" >>~/cloudify/blueprints/k8s-hello-world/inputs.yaml
#  sed 's/^/  /' ~/.kube/config | tee -a ~/cloudify/blueprints/k8s-hello-world/inputs.yaml
  cp ~/.kube/config ~/cloudify/blueprints/k8s-hello-world/kube.config

  cfy blueprints package -o ~/cloudify/blueprints/k8s-hello-world ~/cloudify/blueprints/k8s-hello-world
  cfy blueprints upload -t default_tenant -b k8s-hello-world ~/cloudify/blueprints/k8s-hello-world.tar.gz
  cfy deployments create -t default_tenant -b k8s-hello-world k8s-hello-world
  cfy workflows list -d k8s-hello-world
  cfy executions start install -d k8s-hello-world
  pod_ip=$(kubectl get pods --namespace default -o jsonpath='{.status.podIP}' nginx)
  while [[ "x$pod_ip" == "x" ]]; do
    echo "${FUNCNAME[0]}: nginx pod IP is not yet assigned, waiting 10 seconds"
    sleep 10
    pod_ip=$(kubectl get pods --namespace default -o jsonpath='{.status.podIP}' nginx)
  done
  while ! curl http://$pod_ip ; do
    echo "${FUNCNAME[0]}: nginx pod is not yet responding at http://$pod_ip, waiting 10 seconds"
    sleep 10
  done
  echo "${FUNCNAME[0]}: nginx pod is active at http://$pod_ip"
  curl http://$pod_ip
}

function clean () {
  echo "${FUNCNAME[0]}: Cleanup cloudify"
  # TODO
}

dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'`
case "$1" in
  "prereqs")
    prereqs
    ;;
  "setup")
    setup
    ;;
  "demo")
    demo
    ;;
  "clean")
    clean
    ;;
  *)
    grep '#. ' $0
esac


text:
@interface CYTabBarController : UITabBarController

@end


text:
<?php

use ChurchCRM\dto\SystemURLs;

//Set the page title
include SystemURLs::getDocumentRoot() . '/Include/Header.php';
?>

<?= gettext("Reset Members") ?>

                    <?= gettext("This will remove all the member data, people, and families and can't be undone.") ?>

                    <button type="button" class="btn btn-danger"
                            id="confirm-people"><?= gettext("Reset Families/People") ?></button>

<?= gettext("Reset Database") ?>

                    <?= gettext("This will reset the system data and will restart the system as a new install.") ?>

                    <button type="button" class="btn btn-danger"
                            id="confirm-db"><?= gettext("Reset Database") ?></button>

<?php include SystemURLs::getDocumentRoot() . '/Include/Footer.php'; ?>


text:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="../resources/runner.js"></script>
</head>
<body>
<script>

// Repeatedly send different events to the same node.
let node = document.body;
let depth = 50;
while (depth) {
    const child = document.createElement('div');
    node.appendChild(child);
    node = child;
    depth--;
}
const numEvents = 1000;
const customEvents = Array.from(Array(numEvents)).map((_, i) => {
  return new Event(`foo-${i}`);
});

function run() {
  customEvents.forEach((event) => node.dispatchEvent(event));
}

PerfTestRunner.measureRunsPerSecond({
    description: "Measure events dispatching on same node",
    run: run,
});
</script>
</body>
</html>


text:
""" data iterator for mnist """
import os
import random
import logging
logging.basicConfig(level=logging.INFO)

import mxnet as mx
from mxnet.test_utils import get_cifar10
from mxnet.gluon.data.vision import ImageFolderDataset
from mxnet.gluon.data import DataLoader
from mxnet.contrib.io import DataLoaderIter

def get_cifar10_iterator(batch_size, data_shape, resize=-1, num_parts=1, part_index=0):
    get_cifar10()

    train = mx.io.ImageRecordIter(
        path_imgrec = "data/cifar/train.rec",
        # mean_img    = "data/cifar/mean.bin",
        resize      = resize,
        data_shape  = data_shape,
        batch_size  = batch_size,
        rand_crop   = True,
        rand_mirror = True,
        num_parts=num_parts,
        part_index=part_index)

    val = mx.io.ImageRecordIter(
        path_imgrec = "data/cifar/test.rec",
        # mean_img    = "data/cifar/mean.bin",
        resize      = resize,
        rand_crop   = False,
        rand_mirror = False,
        data_shape  = data_shape,
        batch_size  = batch_size,
        num_parts=num_parts,
        part_index=part_index)

    return train, val

def get_imagenet_transforms(data_shape=224, dtype='float32'):
    def train_transform(image, label):
        image, _ = mx.image.random_size_crop(image, (data_shape, data_shape), 0.08, (3/4., 4/3.))
        image = mx.nd.image.random_flip_left_right(image)
        image = mx.nd.image.to_tensor(image)
        image = mx.nd.image.normalize(image, mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225))
        return mx.nd.cast(image, dtype), label

    def val_transform(image, label):
        image = mx.image.resize_short(image, data_shape + 32)
        image, _ = mx.image.center_crop(image, (data_shape, data_shape))
        image = mx.nd.image.to_tensor(image)
        image = mx.nd.image.normalize(image, mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225))
        return mx.nd.cast(image, dtype), label
    return train_transform, val_transform

def get_imagenet_iterator(root, batch_size, num_workers, data_shape=224, dtype='float32'):
    """Dataset loader with preprocessing."""
    train_dir = os.path.join(root, 'train')
    train_transform, val_transform = get_imagenet_transforms(data_shape, dtype)
    logging.info("Loading image folder %s, this may take a bit long...", train_dir)
    train_dataset = ImageFolderDataset(train_dir, transform=train_transform)
    train_data = DataLoader(train_dataset, batch_size, shuffle=True,
                            last_batch='discard', num_workers=num_workers)
    val_dir = os.path.join(root, 'val')
    if not os.path.isdir(os.path.expanduser(os.path.join(root, 'val', 'n01440764'))):
        user_warning = 'Make sure validation images are stored in one subdir per category, a helper script is available at https://git.io/vNQv1'
        raise ValueError(user_warning)
    logging.info("Loading image folder %s, this may take a bit long...", val_dir)
    val_dataset = ImageFolderDataset(val_dir, transform=val_transform)
    val_data = DataLoader(val_dataset, batch_size, last_batch='keep', num_workers=num_workers)
    return DataLoaderIter(train_data, dtype), DataLoaderIter(val_data, dtype)

class DummyIter(mx.io.DataIter):
    def __init__(self, batch_size, data_shape, batches = 100):
        super(DummyIter, self).__init__(batch_size)
        self.data_shape = (batch_size,) + data_shape
        self.label_shape = (batch_size,)
        self.provide_data = [('data', self.data_shape)]
        self.provide_label = [('softmax_label', self.label_shape)]
        self.batch = mx.io.DataBatch(data=[mx.nd.zeros(self.data_shape)],
                                     label=[mx.nd.zeros(self.label_shape)])
        self._batches = 0
        self.batches = batches

    def next(self):
        if self._batches < self.batches:
            self._batches += 1
            return self.batch
        else:
            self._batches = 0
            raise StopIteration

def dummy_iterator(batch_size, data_shape):
    return DummyIter(batch_size, data_shape), DummyIter(batch_size, data_shape)

class ImagePairIter(mx.io.DataIter):
    def __init__(self, path, data_shape, label_shape, batch_size=64, flag=0, input_aug=None, target_aug=None):
        super(ImagePairIter, self).__init__(batch_size)
        self.data_shape = (batch_size,) + data_shape
        self.label_shape = (batch_size,) + label_shape
        self.input_aug = input_aug
        self.target_aug = target_aug
        self.provide_data = [('data', self.data_shape)]
        self.provide_label = [('label', self.label_shape)]
        is_image_file = lambda fn: any(fn.endswith(ext) for ext in [".png", ".jpg", ".jpeg"])
        self.filenames = [os.path.join(path, x) for x in os.listdir(path) if is_image_file(x)]
        self.count = 0
        self.flag = flag
        random.shuffle(self.filenames)

    def next(self):
        from PIL import Image
        if self.count + self.batch_size <= len(self.filenames):
            data = []
            label = []
            for i in range(self.batch_size):
                fn = self.filenames[self.count]
                self.count += 1
                image = Image.open(fn).convert('YCbCr').split()[0]
                if image.size[0] > image.size[1]:
                    image = image.transpose(Image.TRANSPOSE)
                image = mx.nd.expand_dims(mx.nd.array(image), axis=2)
                target = image.copy()
                for aug in self.input_aug:
                    image = aug(image)
                for aug in self.target_aug:
                    target = aug(target)
                data.append(image)
                label.append(target)

            data = mx.nd.concat(*[mx.nd.expand_dims(d, axis=0) for d in data], dim=0)
            label = mx.nd.concat(*[mx.nd.expand_dims(d, axis=0) for d in label], dim=0)
            data = [mx.nd.transpose(data, axes=(0, 3, 1, 2)).astype('float32')/255]
            label = [mx.nd.transpose(label, axes=(0, 3, 1, 2)).astype('float32')/255]

            return mx.io.DataBatch(data=data, label=label)
        else:
            raise StopIteration

    def reset(self):
        self.count = 0
        random.shuffle(self.filenames)


text: based on Fedora 22 with tomcat 8.0.23


text:
#### [PATCH v4 0/4] KVM: X86: Some tracepoint enhancements
##### From: Peter Xu <peterx@redhat.com>

```c
From patchwork Fri Sep  6 02:17:18 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Peter Xu <peterx@redhat.com>
X-Patchwork-Id: 11134247
Return-Path: <SRS0=9Awg=XB=vger.kernel.org=kvm-owner@kernel.org>
Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org
 [172.30.200.123])
	by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 645EE1398
	for <patchwork-kvm@patchwork.kernel.org>;
 Fri,  6 Sep 2019 02:17:35 +0000 (UTC)
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
	by mail.kernel.org (Postfix) with ESMTP id 636D62082E
	for <patchwork-kvm@patchwork.kernel.org>;
 Fri,  6 Sep 2019 02:17:35 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S2387741AbfIFCRe (ORCPT
        <rfc822;patchwork-kvm@patchwork.kernel.org>);
        Thu, 5 Sep 2019 22:17:34 -0400
Received: from mx1.redhat.com ([209.132.183.28]:55786 "EHLO mx1.redhat.com"
        rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
        id S1728628AbfIFCRd (ORCPT <rfc822;kvm@vger.kernel.org>);
        Thu, 5 Sep 2019 22:17:33 -0400
Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com
 [209.85.210.199])
        (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
        (No client certificate requested)
        by mx1.redhat.com (Postfix) with ESMTPS id 98B6B7FDFF
        for <kvm@vger.kernel.org>; Fri,  6 Sep 2019 02:17:33 +0000 (UTC)
Received: by mail-pf1-f199.google.com with SMTP id i187so3361357pfc.10
        for <kvm@vger.kernel.org>; Thu, 05 Sep 2019 19:17:33 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version
         :content-transfer-encoding;
        bh=aBUS+fgsamAUOZtSEp++jlkJB5YgKT1csWUc+zQUKS4=;
        b=SAK4GanL7UBxn5aJIEWoEdSWWjzycKKhl5Ts40P+9Ld5JDqxIujeBnn/DrVwRLwp5C
         odmeiM77Z/88n8sJBWN4fAoOvrRMGobpp9NP1IcWdJrn3AYs3MTOT+kKxo4HvUp54mz4
         UlGx5wWMljWpcO918Dsx72pZTHPuGzww8o8ALsaYIT53jpPwavW3a5vkrbAeM88USOjq
         juLRMLe7tn3vDzkxn/NfnkA3kl1KeIXl232Uas1BOruxi3pwBUkCxn5XQNAQrCKsO6iG
         t76LLqg8FZdcNCTAJLsfkOrhZnmg30xST3wYugvwlNPeKluUa06Chdy2ratUhhvk6HNX
         VpmA==
X-Gm-Message-State: APjAAAU0VzotCI0xi3M3oI2fbq4qcvIu+m9qrKxJcHgvqNOJYmYaUV8Y
        FzwFGpl+BdJ5lqOhHSs8tcBl3p/6tV0pckjCWbv4d77NDgX3BB3NQWqsB/kH1UoFZmmWeZiiIMS
        QmKfrdt9bzdNF
X-Received: by 2002:a62:e717:: with SMTP id s23mr7759987pfh.71.1567736253137;
        Thu, 05 Sep 2019 19:17:33 -0700 (PDT)
X-Google-Smtp-Source:
 APXvYqzCQJM/WuwJ79nbWX4bQwimjvaO+Ug+0hsWoiE4Vf9iu3itMcfU3iYer2r464k1bCxIb1dlRA==
X-Received: by 2002:a62:e717:: with SMTP id s23mr7759963pfh.71.1567736252846;
        Thu, 05 Sep 2019 19:17:32 -0700 (PDT)
Received: from xz-x1.redhat.com ([209.132.188.80])
        by smtp.gmail.com with ESMTPSA id
 a11sm8212359pfg.94.2019.09.05.19.17.29
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 05 Sep 2019 19:17:32 -0700 (PDT)
From: Peter Xu <peterx@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: Sean Christopherson <sean.j.christopherson@intel.com>,
        Paolo Bonzini <pbonzini@redhat.com>,
        Wanpeng Li <kernellwp@gmail.com>,
        Krish Sadhukhan <krish.sadhukhan@oracle.com>, peterx@redhat.com
Subject: [PATCH v4 0/4] KVM: X86: Some tracepoint enhancements
Date: Fri,  6 Sep 2019 10:17:18 +0800
Message-Id: <20190906021722.2095-1-peterx@redhat.com>
X-Mailer: git-send-email 2.21.0
MIME-Version: 1.0
Sender: kvm-owner@vger.kernel.org
Precedence: bulk
List-ID: <kvm.vger.kernel.org>
X-Mailing-List: kvm@vger.kernel.org

v4:
- pick r-b
- swap the last two patches [Sean]

v3:
- use unsigned int for vcpu id [Sean]
- a new patch to fix ple_window type [Sean]

v2:
- fix commit messages, change format of ple window tracepoint [Sean]
- rebase [Wanpeng]

Each small patch explains itself.  I noticed them when I'm tracing
some IRQ paths and I found them helpful at least to me.

Please have a look.  Thanks,

Peter Xu (4):
  KVM: X86: Trace vcpu_id for vmexit
  KVM: X86: Remove tailing newline for tracepoints
  KVM: VMX: Change ple_window type to unsigned int
  KVM: X86: Tune PLE Window tracepoint

 arch/x86/kvm/svm.c     | 16 ++++++++--------
 arch/x86/kvm/trace.h   | 34 ++++++++++++++--------------------
 arch/x86/kvm/vmx/vmx.c | 18 ++++++++++--------
 arch/x86/kvm/vmx/vmx.h |  2 +-
 arch/x86/kvm/x86.c     |  2 +-
 5 files changed, 34 insertions(+), 38 deletions(-)
```
#### [PATCH v18 0/6] Add ARMv8 RAS virtualization support in QEMU
##### From: Xiang Zheng <zhengxiang9@huawei.com>

```c
From patchwork Fri Sep  6 08:31:46 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Xiang Zheng <zhengxiang9@huawei.com>
X-Patchwork-Id: 11134763
Return-Path: <SRS0=9Awg=XB=vger.kernel.org=kvm-owner@kernel.org>
Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org
 [172.30.200.123])
	by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9446F16B1
	for <patchwork-kvm@patchwork.kernel.org>;
 Fri,  6 Sep 2019 08:33:20 +0000 (UTC)
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
	by mail.kernel.org (Postfix) with ESMTP id 63F5D2084F
	for <patchwork-kvm@patchwork.kernel.org>;
 Fri,  6 Sep 2019 08:33:20 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S2387975AbfIFIdT (ORCPT
        <rfc822;patchwork-kvm@patchwork.kernel.org>);
        Fri, 6 Sep 2019 04:33:19 -0400
Received: from szxga07-in.huawei.com ([45.249.212.35]:46196 "EHLO huawei.com"
        rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP
        id S1732698AbfIFIdS (ORCPT <rfc822;kvm@vger.kernel.org>);
        Fri, 6 Sep 2019 04:33:18 -0400
Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58])
        by Forcepoint Email with ESMTP id A772C54CF12C87E94E54;
        Fri,  6 Sep 2019 16:33:15 +0800 (CST)
Received: from HGHY1z004218071.china.huawei.com (10.177.29.32) by
 DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id
 14.3.439.0; Fri, 6 Sep 2019 16:33:07 +0800
From: Xiang Zheng <zhengxiang9@huawei.com>
To: <pbonzini@redhat.com>, <mst@redhat.com>, <imammedo@redhat.com>,
        <shannon.zhaosl@gmail.com>, <peter.maydell@linaro.org>,
        <lersek@redhat.com>, <james.morse@arm.com>,
        <gengdongjiu@huawei.com>, <mtosatti@redhat.com>, <rth@twiddle.net>,
        <ehabkost@redhat.com>, <jonathan.cameron@huawei.com>,
        <xuwei5@huawei.com>, <kvm@vger.kernel.org>,
        <qemu-devel@nongnu.org>, <qemu-arm@nongnu.org>,
        <linuxarm@huawei.com>
CC: <zhengxiang9@huawei.com>, <wanghaibin.wang@huawei.com>
Subject: [PATCH v18 0/6] Add ARMv8 RAS virtualization support in QEMU
Date: Fri, 6 Sep 2019 16:31:46 +0800
Message-ID: <20190906083152.25716-1-zhengxiang9@huawei.com>
X-Mailer: git-send-email 2.15.1.windows.2
MIME-Version: 1.0
Content-Type: text/plain
X-Originating-IP: [10.177.29.32]
X-CFilter-Loop: Reflected
Sender: kvm-owner@vger.kernel.org
Precedence: bulk
List-ID: <kvm.vger.kernel.org>
X-Mailing-List: kvm@vger.kernel.org

In the ARMv8 platform, the CPU error types are synchronous external abort(SEA)
and SError Interrupt (SEI). If exception happens in guest, sometimes it's better
for guest to perform the recovery, because host does not know the detailed
information of guest. For example, if an exception happens in a user-space
application within guest, host does not know which application encounters
errors.

For the ARMv8 SEA/SEI, KVM or host kernel delivers SIGBUS to notify userspace.
After user space gets the notification, it will record the CPER into guest GHES
buffer and inject an exception or IRQ into guest.

In the current implementation, if the type of SIGBUS is BUS_MCEERR_AR, we will
treat it as a synchronous exception, and notify guest with ARMv8 SEA
notification type after recording CPER into guest.

This series of patches are based on Qemu 4.1, which include two parts:
1. Generate APEI/GHES table.
2. Handle the SIGBUS signal, record the CPER in runtime and fill it into guest
   memory, then notify guest according to the type of SIGBUS.

The whole solution was suggested by James(james.morse@arm.com); The solution of
APEI section was suggested by Laszlo(lersek@redhat.com).
Show some discussions in [1].

This series of patches have already been tested on ARM64 platform with RAS
feature enabled:
Show the APEI part verification result in [2].
Show the BUS_MCEERR_AR SIGBUS handling verification result in [3].
---

Since Dongjiu is too busy to do this work, I will finish the rest work on behalf
of him.

---
Change since v17:
1. Improve some commit messages and comments.
2. Fix some code-style problems.
3. Add a *ras* machine option.
4. Move HEST/GHES related structures and macros into "hw/acpi/acpi_ghes.*".
5. Move HWPoison page functions into "include/sysemu/kvm_int.h".
6. Fix some bugs.
7. Improve the design document.

Change since v16:
1. check whether ACPI table is enabled when handling the memory error in the SIGBUS handler.

Change since v15:
1. Add a doc-comment in the proper format for 'include/exec/ram_addr.h'
2. Remove write_part_cpustate_to_list() because there is another bug fix patch
   has been merged "arm: Allow system registers for KVM guests to be changed by QEMU code"
3. Add some comments for kvm_inject_arm_sea() in 'target/arm/kvm64.c'
4. Compare the arm_current_el() return value to 0,1,2,3, not to PSTATE_MODE_* constants.
5. Change the RAS support wasn't introduced before 4.1 QEMU version.
6. Move the no_ras flag  patch to begin in this series

Change since v14:
1. Remove the BUS_MCEERR_AO handling logic because this asynchronous signal was masked by main thread
2. Address some Igor Mammedov's comments(ACPI part)
   1) change the comments for the enum AcpiHestNotifyType definition and remove ditto in patch 1
   2) change some patch commit messages and separate "APEI GHES table generation" patch to more patches.
3. Address some peter's comments(arm64 Synchronous External Abort injection)
   1) change some code notes
   2) using arm_current_el() for current EL
   2) use the helper functions for those (syn_data_abort_*).

Change since v13:
1. Move the patches that set guest ESR and inject virtual SError out of this series
2. Clean and optimize the APEI part patches
3. Update the commit messages and add some comments for the code

Change since v12:
1. Address Paolo's comments to move HWPoisonPage definition to accel/kvm/kvm-all.c
2. Only call kvm_cpu_synchronize_state() when get the BUS_MCEERR_AR signal
3. Only add and enable GPIO-Signal and ARMv8 SEA two hardware error sources
4. Address Michael's comments to not sync SPDX from Linux kernel header file

Change since v11:
Address James's comments(james.morse@arm.com)
1. Check whether KVM has the capability to to set ESR instead of detecting host CPU RAS capability
2. For SIGBUS_MCEERR_AR SIGBUS, use Synchronous-External-Abort(SEA) notification type
   for SIGBUS_MCEERR_AO SIGBUS, use GPIO-Signal notification

Address Shannon's comments(for ACPI part):
1. Unify hest_ghes.c and hest_ghes.h license declaration
2. Remove unnecessary including "qmp-commands.h" in hest_ghes.c
3. Unconditionally add guest APEI table based on James's comments(james.morse@arm.com)
4. Add a option to virt machine for migration compatibility. On new virt machine it's on
   by default while off for old ones, we enabled it since 2.12
5. Refer to the ACPI spec version which introduces Hardware Error Notification first time
6. Add ACPI_HEST_NOTIFY_RESERVED notification type

Address Igor's comments(for ACPI part):
1. Add doc patch first which will describe how it's supposed to work between QEMU/firmware/guest
   OS with expected flows.
2. Move APEI diagrams into doc/spec patch
3. Remove redundant g_malloc in ghes_record_cper()
4. Use build_append_int_noprefix() API to compose whole error status block and whole APEI table,
   and try to get rid of most structures in patch 1, as they will be left unused after that
5. Reuse something like https://github.com/imammedo/qemu/commit/3d2fd6d13a3ea298d2ee814835495ce6241d085c
   to build GAS
6. Remove much offsetof() in the function
7. Build independent tables first and only then build dependent tables passing to it pointers
   to previously build table if necessary.
8. Redefine macro GHES_ACPI_HEST_NOTIFY_RESERVED to ACPI_HEST_ERROR_SOURCE_COUNT to avoid confusion

Address Peter Maydell's comments
1. linux-headers is done as a patch of their own created using scripts/update-linux-headers.sh run against a
   mainline kernel tree
2. Tested whether this patchset builds OK on aarch32
3. Abstract Hwpoison page adding code  out properly into a cpu-independent source file from target/i386/kvm.c,
   such as kvm-all.c
4. Add doc-comment formatted documentation comment for new globally-visible function prototype in a header

---
[1]:
https://lkml.org/lkml/2017/2/27/246
https://patchwork.kernel.org/patch/9633105/
https://patchwork.kernel.org/patch/9925227/

[2]:
Note: the UEFI(QEMU_EFI.fd) is needed if guest want to use ACPI table.

After guest boot up, dump the APEI table, then can see the initialized table
(1) # iasl -p ./HEST -d /sys/firmware/acpi/tables/HEST
(2) # cat HEST.dsl

    ..................................................................................
    [308h 0776   2]                Subtable Type : 000A [Generic Hardware Error Source V2]
    [30Ah 0778   2]                    Source Id : 0001
    [30Ch 0780   2]            Related Source Id : FFFF
    [30Eh 0782   1]                     Reserved : 00
    [30Fh 0783   1]                      Enabled : 01
    [310h 0784   4]       Records To Preallocate : 00000001
    [314h 0788   4]      Max Sections Per Record : 00000001
    [318h 0792   4]          Max Raw Data Length : 00001000

    [31Ch 0796  12]         Error Status Address : [Generic Address Structure]
    [31Ch 0796   1]                     Space ID : 00 [SystemMemory]
    [31Dh 0797   1]                    Bit Width : 40
    [31Eh 0798   1]                   Bit Offset : 00
    [31Fh 0799   1]         Encoded Access Width : 04 [QWord Access:64]
    [320h 0800   8]                      Address : 00000000785D0040

    [328h 0808  28]                       Notify : [Hardware Error Notification Structure]
    [328h 0808   1]                  Notify Type : 08 [SEA]
    [329h 0809   1]                Notify Length : 1C
    [32Ah 0810   2]   Configuration Write Enable : 0000
    [32Ch 0812   4]                 PollInterval : 00000000
    [330h 0816   4]                       Vector : 00000000
    [334h 0820   4]      Polling Threshold Value : 00000000
    [338h 0824   4]     Polling Threshold Window : 00000000
    [33Ch 0828   4]        Error Threshold Value : 00000000
    [340h 0832   4]       Error Threshold Window : 00000000

    [344h 0836   4]    Error Status Block Length : 00001000
    [348h 0840  12]            Read Ack Register : [Generic Address Structure]
    [348h 0840   1]                     Space ID : 00 [SystemMemory]
    [349h 0841   1]                    Bit Width : 40
    [34Ah 0842   1]                   Bit Offset : 00
    [34Bh 0843   1]         Encoded Access Width : 04 [QWord Access:64]
    [34Ch 0844   8]                      Address : 00000000785D0098

    [354h 0852   8]            Read Ack Preserve : 00000000FFFFFFFE
    [35Ch 0860   8]               Read Ack Write : 0000000000000001

    .....................................................................................

(3) After a synchronous external abort(SEA) happen, Qemu receive a SIGBUS and
    filled the CPER into guest GHES memory.  For example, according to above table,
    the address that contains the physical address of a block of memory that holds
    the error status data for this abort is 0x00000000785D0040
(4) the address for SEA notification error source is 0x785d80b0
    (qemu) xp /1 0x00000000785D0040
    00000000785d0040: 0x785d80b0

(5) check the content of generic error status block and generic error data entry
    (qemu) xp /100x 0x785d80b0
    00000000785d80b0: 0x00000001 0x00000000 0x00000000 0x00000098
    00000000785d80c0: 0x00000000 0xa5bc1114 0x4ede6f64 0x833e63b8
    00000000785d80d0: 0xb1837ced 0x00000000 0x00000300 0x00000050
    00000000785d80e0: 0x00000000 0x00000000 0x00000000 0x00000000
    00000000785d80f0: 0x00000000 0x00000000 0x00000000 0x00000000
    00000000785d8100: 0x00000000 0x00000000 0x00000000 0x00004002
(6) check the OSPM's ACK value(for example SEA)
    /* Before OSPM acknowledges the error, check the ACK value */
    (qemu) xp /1 0x00000000785D0098
    00000000785d00f0: 0x00000000

    /* After OSPM acknowledges the error, check the ACK value, it change to 1 from 0 */
    (qemu) xp /1 0x00000000785D0098
    00000000785d00f0: 0x00000001

[3]: KVM deliver "BUS_MCEERR_AR" to Qemu, Qemu record the guest CPER and inject
    synchronous external abort to notify guest, then guest do the recovery.

[ 1552.516170] Synchronous External Abort: synchronous external abort (0x92000410) at 0x000000003751c6b4
[ 1553.074073] {1}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 8
[ 1553.081654] {1}[Hardware Error]: event severity: recoverable
[ 1554.034191] {1}[Hardware Error]:  Error 0, type: recoverable
[ 1554.037934] {1}[Hardware Error]:   section_type: memory error
[ 1554.513261] {1}[Hardware Error]:   physical_address: 0x0000000040fa6000
[ 1554.513944] {1}[Hardware Error]:   error_type: 0, unknown
[ 1555.041451] Memory failure: 0x40fa6: Killing mca-recover:1296 due to hardware memory corruption
[ 1555.373116] Memory failure: 0x40fa6: recovery action for dirty LRU page: Recovered

Dongjiu Geng (6):
  hw/arm/virt: Introduce RAS platform version and RAS machine option
  docs: APEI GHES generation and CPER record description
  ACPI: Add APEI GHES table generation support
  KVM: Move hwpoison page related functions into
    include/sysemu/kvm_int.h
  target-arm: kvm64: inject synchronous External Abort
  target-arm: kvm64: handle SIGBUS signal from kernel or KVM

 accel/kvm/kvm-all.c             |  33 +++
 default-configs/arm-softmmu.mak |   1 +
 docs/specs/acpi_hest_ghes.txt   |  88 ++++++
 hw/acpi/Kconfig                 |   4 +
 hw/acpi/Makefile.objs           |   1 +
 hw/acpi/acpi_ghes.c             | 462 ++++++++++++++++++++++++++++++++
 hw/acpi/aml-build.c             |   2 +
 hw/arm/virt-acpi-build.c        |  12 +
 hw/arm/virt.c                   |  33 +++
 include/hw/acpi/acpi_ghes.h     | 143 ++++++++++
 include/hw/acpi/aml-build.h     |   1 +
 include/hw/arm/virt.h           |   2 +
 include/sysemu/kvm.h            |   2 +-
 include/sysemu/kvm_int.h        |  23 ++
 target/arm/helper.c             |   2 +-
 target/arm/internals.h          |   5 +-
 target/arm/kvm.c                |   3 +
 target/arm/kvm64.c              |  73 +++++
 target/arm/tlb_helper.c         |   2 +-
 target/i386/kvm.c               |  34 ---
 20 files changed, 887 insertions(+), 39 deletions(-)
 create mode 100644 docs/specs/acpi_hest_ghes.txt
 create mode 100644 hw/acpi/acpi_ghes.c
 create mode 100644 include/hw/acpi/acpi_ghes.h
```
#### [PATCH v8 0/7] mm / virtio: Provide support for unused page
##### From: Alexander Duyck <alexander.duyck@gmail.com>

```c
From patchwork Fri Sep  6 14:53:21 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Alexander Duyck <alexander.duyck@gmail.com>
X-Patchwork-Id: 11135457
Return-Path: <SRS0=9Awg=XB=vger.kernel.org=kvm-owner@kernel.org>
Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org
 [172.30.200.123])
	by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C6911395
	for <patchwork-kvm@patchwork.kernel.org>;
 Fri,  6 Sep 2019 14:53:28 +0000 (UTC)
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
	by mail.kernel.org (Postfix) with ESMTP id 0C72420842
	for <patchwork-kvm@patchwork.kernel.org>;
 Fri,  6 Sep 2019 14:53:27 +0000 (UTC)
Authentication-Results: mail.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com
 header.b="vTKtJTgG"
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S2394658AbfIFOxY (ORCPT
        <rfc822;patchwork-kvm@patchwork.kernel.org>);
        Fri, 6 Sep 2019 10:53:24 -0400
Received: from mail-pg1-f193.google.com ([209.85.215.193]:44929 "EHLO
        mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
        with ESMTP id S2390603AbfIFOxY (ORCPT <rfc822;kvm@vger.kernel.org>);
        Fri, 6 Sep 2019 10:53:24 -0400
Received: by mail-pg1-f193.google.com with SMTP id i18so3621327pgl.11;
        Fri, 06 Sep 2019 07:53:23 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=subject:from:to:cc:date:message-id:user-agent:mime-version
         :content-transfer-encoding;
        bh=rjoMQB+Mq/0ixcTPll/Yse8OkMaybjf8D43LT3d+qZU=;
        b=vTKtJTgGYzko+zxYP9jTUKCr0CEaCV8I9MWTE+JyW+0OCfmB3oALdTDUOnaXz9Boph
         sOrEhQLuUtARbbCrM9mbjLUDJDbymk9ylw4rQ5oSTpg+pb4XNuRhjzi3JpIfJ0SfDlx/
         Vj5hl15j1P7NiEXVuQvkc9qmTh6Az1uyepCMS6can8870ArD2s+d2XC8iAw8vwP4ko6c
         WEm5lyyrSpSn+T0JeRVy5bxIAsQtvmtN7J/b/A9dF+a96J5ZscVpOLhczqSESCpezWeH
         2FnbAhz/LvJkxEDAcVs9REOq5YfRrVUq0ubJpYaSeVS5tlbfNEhdUgXA0Mbp+J25IXZr
         Xp+A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:from:to:cc:date:message-id:user-agent
         :mime-version:content-transfer-encoding;
        bh=rjoMQB+Mq/0ixcTPll/Yse8OkMaybjf8D43LT3d+qZU=;
        b=UckbjvlBUx8FFEpJPZ9X4qXzqkATQnXqPa3fUxQhYfbEgOc3mbUxuZIeZKVrCNzoU4
         pmGDJyhKyTybbxfpXlkoftf7f+DrR9laNjYPfYONDqqA6ucevIo52Cla7lzZEVblD01s
         RgcLXUxliyv3zJfrs6hBdiqjtAoCHTqgEk+TdF3PYUneuA6wYjAH1H6KXNPvxcEzvosG
         ePbY0oplt5egd76V6doKH9EXwa7LrtJ/M1d9Dnc1F/ilkgU48YRGsYhAfXSPqp1SV5Ww
         iourUU8gzvnpz8PJlH8pOsjD33FpOU31N8hAOyXVrWC13GkVby9+HGjb+T4AQJ8/jUGR
         fUhA==
X-Gm-Message-State: APjAAAUjUvofoqu1pp05jKaEIMULZ8yxqP/HcGlh4QRelMKsNo9CeuJS
        BHHFQ27mwz7N1ckvnme+fjo=
X-Google-Smtp-Source:
 APXvYqz/VYIeGaQ7/nloI3Gq0Su4n93sg05uXSyruDOcPtM8ukUWtB0e4mHXCeiQtVrowWPTWIhBaQ==
X-Received: by 2002:a62:ee0a:: with SMTP id
 e10mr11272952pfi.197.1567781602887;
        Fri, 06 Sep 2019 07:53:22 -0700 (PDT)
Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0])
        by smtp.gmail.com with ESMTPSA id
 c1sm7901978pfd.117.2019.09.06.07.53.21
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 06 Sep 2019 07:53:22 -0700 (PDT)
Subject: [PATCH v8 0/7] mm / virtio: Provide support for unused page
 reporting
From: Alexander Duyck <alexander.duyck@gmail.com>
To: nitesh@redhat.com, kvm@vger.kernel.org, mst@redhat.com,
        david@redhat.com, dave.hansen@intel.com,
        linux-kernel@vger.kernel.org, willy@infradead.org,
        mhocko@kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org,
        virtio-dev@lists.oasis-open.org, osalvador@suse.de
Cc: yang.zhang.wz@gmail.com, pagupta@redhat.com, riel@surriel.com,
        konrad.wilk@oracle.com, lcapitulino@redhat.com,
        wei.w.wang@intel.com, aarcange@redhat.com, pbonzini@redhat.com,
        dan.j.williams@intel.com, alexander.h.duyck@linux.intel.com
Date: Fri, 06 Sep 2019 07:53:21 -0700
Message-ID: <20190906145213.32552.30160.stgit@localhost.localdomain>
User-Agent: StGit/0.17.1-dirty
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Sender: kvm-owner@vger.kernel.org
Precedence: bulk
List-ID: <kvm.vger.kernel.org>
X-Mailing-List: kvm@vger.kernel.org

This series provides an asynchronous means of reporting to a hypervisor
that a guest page is no longer in use and can have the data associated
with it dropped. To do this I have implemented functionality that allows
for what I am referring to as unused page reporting

The functionality for this is fairly simple. When enabled it will allocate
statistics to track the number of reported pages in a given free area.
When the number of free pages exceeds this value plus a high water value,
currently 32, it will begin performing page reporting which consists of
pulling pages off of free list and placing them into a scatter list. The
scatterlist is then given to the page reporting device and it will perform
the required action to make the pages "reported", in the case of
virtio-balloon this results in the pages being madvised as MADV_DONTNEED
and as such they are forced out of the guest. After this they are placed
back on the free list, and an additional bit is added if they are not
merged indicating that they are a reported buddy page instead of a
standard buddy page. The cycle then repeats with additional non-reported
pages being pulled until the free areas all consist of reported pages.

I am leaving a number of things hard-coded such as limiting the lowest
order processed to PAGEBLOCK_ORDER, and have left it up to the guest to
determine what the limit is on how many pages it wants to allocate to
process the hints. The upper limit for this is based on the size of the
queue used to store the scattergather list.

My primary testing has just been to verify the memory is being freed after
allocation by running memhog 40g on a 40g guest and watching the total
free memory via /proc/meminfo on the host. With this I have verified most
of the memory is freed after each iteration. As far as performance I have
been mainly focusing on the will-it-scale/page_fault1 test running with
16 vcpus. I have modified it to use Transparent Huge Pages. With this I
see almost no difference, -0.08%, with the patches applied and the feature
disabled. I see a regression of -0.86% with the feature enabled, but the
madvise disabled in the hypervisor due to a device being assigned. With
the feature fully enabled I see a regression of -3.27% versus the baseline
without these patches applied. In my testing I found that most of the
overhead was due to the page zeroing that comes as a result of the pages
having to be faulted back into the guest.

One side effect of these patches is that the guest becomes much more
resilient in terms of NUMA locality. With the pages being freed and then
reallocated when used it allows for the pages to be much closer to the
active thread, and as a result there can be situations where this patch
set will out-perform the stock kernel when the guest memory is not local
to the guest vCPUs. To avoid that in my testing I set the affinity of all
the vCPUs and QEMU instance to the same node.

Changes from the RFC:
https://lore.kernel.org/lkml/20190530215223.13974.22445.stgit@localhost.localdomain/
Moved aeration requested flag out of aerator and into zone->flags.
Moved boundary out of free_area and into local variables for aeration.
Moved aeration cycle out of interrupt and into workqueue.
Left nr_free as total pages instead of splitting it between raw and aerated.
Combined size and physical address values in virtio ring into one 64b value.

Changes from v1:
https://lore.kernel.org/lkml/20190619222922.1231.27432.stgit@localhost.localdomain/
Dropped "waste page treatment" in favor of "page hinting"
Renamed files and functions from "aeration" to "page_hinting"
Moved from page->lru list to scatterlist
Replaced wait on refcnt in shutdown with RCU and cancel_delayed_work_sync
Virtio now uses scatterlist directly instead of intermediate array
Moved stats out of free_area, now in separate area and pointed to from zone
Merged patch 5 into patch 4 to improve review-ability
Updated various code comments throughout

Changes from v2:
https://lore.kernel.org/lkml/20190724165158.6685.87228.stgit@localhost.localdomain/
Dropped "page hinting" in favor of "page reporting"
Renamed files from "hinting" to "reporting"
Replaced "Hinted" page type with "Reported" page flag
Added support for page poisoning while hinting is active
Add QEMU patch that implements PAGE_POISON feature

Changes from v3:
https://lore.kernel.org/lkml/20190801222158.22190.96964.stgit@localhost.localdomain/
Added mutex lock around page reporting startup and shutdown
Fixed reference to "page aeration" in patch 2
Split page reporting function bit out into separate QEMU patch
Limited capacity of scatterlist to vq size - 1 instead of vq size
Added exception handling for case of virtio descriptor allocation failure

Changes from v4:
https://lore.kernel.org/lkml/20190807224037.6891.53512.stgit@localhost.localdomain/
Replaced spin_(un)lock with spin_(un)lock_irq in page_reporting_cycle()
Dropped if/continue for ternary operator in page_reporting_process()
Added checks for isolate and cma types to for_each_reporting_migratetype_order
Added virtio-dev, Michal Hocko, and Oscar Salvador to to:/cc:
Rebased on latest linux-next and QEMU git trees

Changes from v5:
https://lore.kernel.org/lkml/20190812213158.22097.30576.stgit@localhost.localdomain/
Replaced spin_(un)lock with spin_(un)lock_irq in page_reporting_startup()
Updated shuffle code to use "shuffle_pick_tail" and updated patch description
Dropped storage of order and migratettype while page is being reported
Used get_pfnblock_migratetype to determine migratetype of page
Renamed put_reported_page to free_reported_page, added order as argument
Dropped check for CMA type as I believe we should be reporting those
Added code to allow moving of reported pages into and out of isolation
Defined page reporting order as minimum of Huge Page size vs MAX_ORDER - 1
Cleaned up use of static branch usage for page_reporting_notify_enabled

Changes from v6:
https://lore.kernel.org/lkml/20190821145806.20926.22448.stgit@localhost.localdomain/
Rebased on linux-next for 20190903
Added jump label to __page_reporting_request so we release RCU read lock
Removed "- 1" from capacity limit based on virtio ring
Added code to verify capacity is non-zero or return error on startup

Changes from v7:
https://lore.kernel.org/lkml/20190904150920.13848.32271.stgit@localhost.localdomain/
Updated poison fixes to clear flag if "nosanity" is enabled in kernel config
Split shuffle per-cpu optimization into seperate patch
Moved check for !phdev->capacity into reporting patch where it belongs
Added Reviewed-by tags received for v7
---

Alexander Duyck (7):
      mm: Add per-cpu logic to page shuffling
      mm: Adjust shuffle code to allow for future coalescing
      mm: Move set/get_pcppage_migratetype to mmzone.h
      mm: Use zone and order instead of free area in free_list manipulators
      mm: Introduce Reported pages
      virtio-balloon: Pull page poisoning config out of free page hinting
      virtio-balloon: Add support for providing unused page reports to host

 drivers/virtio/Kconfig              |    1
 drivers/virtio/virtio_balloon.c     |   87 ++++++++-
 include/linux/mmzone.h              |  124 ++++++++-----
 include/linux/page-flags.h          |   11 +
 include/linux/page_reporting.h      |  177 ++++++++++++++++++
 include/uapi/linux/virtio_balloon.h |    1
 mm/Kconfig                          |    5 +
 mm/Makefile                         |    1
 mm/internal.h                       |   18 ++
 mm/memory_hotplug.c                 |    1
 mm/page_alloc.c                     |  216 ++++++++++++++++------
 mm/page_reporting.c                 |  340 +++++++++++++++++++++++++++++++++++
 mm/shuffle.c                        |   40 ++--
 mm/shuffle.h                        |   12 +
 14 files changed, 902 insertions(+), 132 deletions(-)
 create mode 100644 include/linux/page_reporting.h
 create mode 100644 mm/page_reporting.c

--
```
#### [kvm-unit-tests PATCH 0/3] x86: Cleanup max test CPUs
##### From: Sean Christopherson <sean.j.christopherson@intel.com>

```c
From patchwork Fri Sep  6 16:34:47 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Sean Christopherson <sean.j.christopherson@intel.com>
X-Patchwork-Id: 11135683
Return-Path: <SRS0=9Awg=XB=vger.kernel.org=kvm-owner@kernel.org>
Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org
 [172.30.200.123])
	by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6BEB41395
	for <patchwork-kvm@patchwork.kernel.org>;
 Fri,  6 Sep 2019 16:34:52 +0000 (UTC)
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
	by mail.kernel.org (Postfix) with ESMTP id 52CC02082C
	for <patchwork-kvm@patchwork.kernel.org>;
 Fri,  6 Sep 2019 16:34:52 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S2390380AbfIFQev (ORCPT
        <rfc822;patchwork-kvm@patchwork.kernel.org>);
        Fri, 6 Sep 2019 12:34:51 -0400
Received: from mga02.intel.com ([134.134.136.20]:9378 "EHLO mga02.intel.com"
        rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
        id S2388260AbfIFQev (ORCPT <rfc822;kvm@vger.kernel.org>);
        Fri, 6 Sep 2019 12:34:51 -0400
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga007.jf.intel.com ([10.7.209.58])
  by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 06 Sep 2019 09:34:50 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.64,473,1559545200";
   d="scan'208";a="174327224"
Received: from sjchrist-coffee.jf.intel.com ([10.54.74.41])
  by orsmga007.jf.intel.com with ESMTP; 06 Sep 2019 09:34:50 -0700
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
 =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= <rkrcmar@redhat.com>
Cc: kvm@vger.kernel.org, Evgeny Yakovlev <wrfsh@yandex-team.ru>
Subject: [kvm-unit-tests PATCH 0/3] x86: Cleanup max test CPUs
Date: Fri,  6 Sep 2019 09:34:47 -0700
Message-Id: <20190906163450.30797-1-sean.j.christopherson@intel.com>
X-Mailer: git-send-email 2.22.0
MIME-Version: 1.0
Sender: kvm-owner@vger.kernel.org
Precedence: bulk
List-ID: <kvm.vger.kernel.org>
X-Mailing-List: kvm@vger.kernel.org

Fix a bug Evgeny reported where init_apic_map() can cause random
corruption due accessing random bytes far beyond the bounds of
online_cpus.  Take the opportunity to bump the max number of test CPUs
to a realistic maximum, i.e. what kvm-unit-tests can support without a
major rework.

Sean Christopherson (3):
  x86: Fix out of bounds access when processing online_cpus
  x86: Declare online_cpus based on MAX_TEST_CPUS
  x86: Bump max number of test CPUs to 255

 lib/x86/apic-defs.h | 2 +-
 lib/x86/apic.c      | 4 ++--
 lib/x86/smp.c       | 2 --
 x86/cstart.S        | 2 +-
 x86/cstart64.S      | 2 +-
 5 files changed, 5 insertions(+), 7 deletions(-)
```
#### [PATCH v4 0/9] KVM: VMX: Add full nested support for
##### From: Oliver Upton <oupton@google.com>

```c
From patchwork Fri Sep  6 21:03:04 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Oliver Upton <oupton@google.com>
X-Patchwork-Id: 11136057
Return-Path: <SRS0=9Awg=XB=vger.kernel.org=kvm-owner@kernel.org>
Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org
 [172.30.200.123])
	by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B70F41593
	for <patchwork-kvm@patchwork.kernel.org>;
 Fri,  6 Sep 2019 21:03:23 +0000 (UTC)
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
	by mail.kernel.org (Postfix) with ESMTP id 9850421848
	for <patchwork-kvm@patchwork.kernel.org>;
 Fri,  6 Sep 2019 21:03:23 +0000 (UTC)
Authentication-Results: mail.kernel.org;
	dkim=pass (2048-bit key) header.d=google.com header.i=@google.com
 header.b="GI+HZU3F"
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S2388468AbfIFVDW (ORCPT
        <rfc822;patchwork-kvm@patchwork.kernel.org>);
        Fri, 6 Sep 2019 17:03:22 -0400
Received: from mail-pf1-f202.google.com ([209.85.210.202]:41568 "EHLO
        mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
        with ESMTP id S1725872AbfIFVDW (ORCPT <rfc822;kvm@vger.kernel.org>);
        Fri, 6 Sep 2019 17:03:22 -0400
Received: by mail-pf1-f202.google.com with SMTP id g15so5515057pfb.8
        for <kvm@vger.kernel.org>; Fri, 06 Sep 2019 14:03:21 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20161025;
        h=date:message-id:mime-version:subject:from:to:cc;
        bh=X3p9IC5KMyfjhH2AJpSb8AsD49T286nJ6y+FEn+DgIo=;
        b=GI+HZU3FqRbK5SdtZUfHusMTRh1WpfgISUCBrFbWcaPpoZgJPX5Z7t3uBt5nLLgqK5
         aNBnENRONB9tv5WaQi88o21skDUjlyPVI0PxTF6MmhQP/LgQfLPBLvbJcQ890Qw+htRl
         11ESH4eCtSItC074pgr9PMNtTr5g3HjEwmSDffGLxeNnUgXkIhMPW90L176Md/O2rkvE
         Ziol6ves4U4EjCbAhdqWZPZ1lGdI+f7VbEVBczn2hwa312MpBsRmtlIeZRBvyZat6H7q
         nJ5+L5TQdVDBzAuNuS0e3z6YyPkrnJiiYUaMZcOPPQcVhTl7Fo6qgy4WheFq14P3y03F
         PCIw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc;
        bh=X3p9IC5KMyfjhH2AJpSb8AsD49T286nJ6y+FEn+DgIo=;
        b=SMTme3F1/SYCrxxt53JJqtoRIqG2VTXvsb/pOQCbfq5fANSete66X+4zakkJrc4xAR
         xIRzQ5SpbO8j5oqhQiQL01ri8WpkSqo97CM6uQOZaYYhppNnC0Bs5Uz9qBwh30OURNab
         AEE14nnCQmjGSuzqjsjuBUfFp34TgqH0nqecEDOKVP2Sh/2NT4JzJ2xYQniYPXlimsd8
         GoSVUNPAJJeEatGifYP8s3y2Z9rQqzxsAZ0bsmyBeuPzgDM4eHK+YPbmuAFYv+EMhS98
         6RJh3gJcXyX86zrsorjH3gg9V7gLXW7SvmXr61ALXFFts1MTCTqP++irgbMfP7Iy/ehe
         TDPQ==
X-Gm-Message-State: APjAAAWcdaydO3ihYjtCLuZXk5yA3R4CkzWkQE2rnWaITHjw4D6m+Wrq
        uOCq8isSbW+9qpv8u3cBkmsdAPxcVeca8hL1AohLnjqaSY8aSKzqNfYx+ds3O4xapZqWT6gzEkw
        f+QuCcGz+JMD/H5TWXiOsoNU8db5axiwRfxNlAmdoLgsG3aoHNiyQY2yRQg==
X-Google-Smtp-Source:
 APXvYqxNdG4S1T4ON0y0OCcJPNj355A2BQvW+t+xyIbLenbmjjeNG/CrY53WlrKas2Lf8IVcIQY0nUA5d3Y=
X-Received: by 2002:a63:5b52:: with SMTP id l18mr9683664pgm.21.1567803801063;
 Fri, 06 Sep 2019 14:03:21 -0700 (PDT)
Date: Fri,  6 Sep 2019 14:03:04 -0700
Message-Id: <20190906210313.128316-1-oupton@google.com>
Mime-Version: 1.0
X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog
Subject: [PATCH v4 0/9] KVM: VMX: Add full nested support for
 IA32_PERF_GLOBAL_CTRL
From: Oliver Upton <oupton@google.com>
To: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>, "
	=?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= " <rkrcmar@redhat.com>
Cc: Jim Mattson <jmattson@google.com>, Peter Shier <pshier@google.com>,
        Krish Sadhukhan <krish.sadhukhan@oracle.com>,
        Sean Christopherson <sean.j.christopherson@intel.com>,
        Oliver Upton <oupton@google.com>
Content-Type: text/plain; charset="UTF-8"
Sender: kvm-owner@vger.kernel.org
Precedence: bulk
List-ID: <kvm.vger.kernel.org>
X-Mailing-List: kvm@vger.kernel.org

[v1] https://lore.kernel.org/r/20190828234134.132704-1-oupton@google.com
[v2] https://lore.kernel.org/r/20190903213044.168494-1-oupton@google.com
[v3] https://lore.kernel.org/r/20190903215801.183193-1-oupton@google.com

v1 => v2:
 - Add Krish's Co-developed-by and Signed-off-by tags.
 - Fix minor nit to kvm-unit-tests to use 'host' local variable
   throughout test_load_pgc()
 - Teach guest_state_test_main() to check guest state from within nested
   VM
 - Update proposed tests to use guest/host state checks, wherein the
   value is checked from MSR_CORE_PERF_GLOBAL_CTRL.
 - Changelog line wrapping

v2 => v3:
 - Remove the value unchanged condition from
   kvm_is_valid_perf_global_ctrl
 - Add line to changelog for patch 3/8

v3 => v4:
 - Allow tests to set the guest func multiple times
 - Style fixes throughout kvm-unit-tests patches, per Krish's review

This patchset exposes the "load IA32_PERF_GLOBAL_CTRL" to guests for nested
VM-entry and VM-exit. There already was some existing code that supported
the VM-exit ctrl, though it had an issue and was not exposed to the guest
anyway. These patches are based on the original set that Krish Sadhukhan
sent out earlier this year.

Purpose of each patch:

(1) Change the existing code that implemented the VM-exit functionality
    to use kvm_set_msr() to avoid being overwritten by
    atomic_perf_switch_msrs().
(2) Update prepare_vmcs02() to implement the VM-entry functionality,
    again using kvm_set_msr().
(3) Create a helper function for checking the validity of an
    IA32_PERF_GLOBAL_CTRL value against pmu->global_ctrl_mask.
(4) Check guest state on VM-entry as described in the SDM.
(5) Check host state on VM-entry as described in the SDM.
(6) Expose the "load IA32_PERF_GLOBAL_CTRL" VM-entry and VM-exit
    controls if IA32_PERF_GLOBAL_CTRL is a valid MSR.
(7) Modify guest_state_test_main() to check guest state MSRs
(8) Tests in kvm-unit-tests to check the VM-entry and VM-exit controls
    work properly

Oliver Upton (6):
  KVM: nVMX: Use kvm_set_msr to load IA32_PERF_GLOBAL_CTRL on vmexit
  KVM: nVMX: Load GUEST_IA32_PERF_GLOBAL_CTRL MSR on vm-entry
  KVM: VMX: Add helper to check reserved bits in IA32_PERF_GLOBAL_CTRL
  KVM: nVMX: check GUEST_IA32_PERF_GLOBAL_CTRL on VM-Entry
  KVM: nVMX: Check HOST_IA32_PERF_GLOBAL_CTRL on VM-entry
  KVM: nVMX: Expose load IA32_PERF_GLOBAL_CTRL vm control if supported

 arch/x86/kvm/pmu.h           |  6 ++++++
 arch/x86/kvm/vmx/nested.c    | 37 +++++++++++++++++++++++++++++++++---
 arch/x86/kvm/vmx/pmu_intel.c |  5 ++++-
 arch/x86/kvm/vmx/vmx.c       | 21 ++++++++++++++++++++
 arch/x86/kvm/vmx/vmx.h       |  1 +
 5 files changed, 66 insertions(+), 4 deletions(-)
```


text:
var async = require('async');
var logger = require("../../modules/log_manager/log_manager.js");
var utils = require("../../modules/utils/utils.js");
var config = require('./config.json');

exports.moduleTag = 'PluginManager';

exports.loadPlugins = function(app, express) {
	logger.debug("PluginManager::loadPlugins()");
	logger.debug(JSON.stringify(config.pluginManager.plugins));
	logger.debug('PluginManager::loadPlugins() plugins to start:');

	if (config.pluginManager.plugins.length > 0) {
		for (var i = 0; i < config.pluginManager.plugins.length; i++) {
			logger.debug(' - ', config.pluginManager.plugins[i].file);
		}

		var q = async.queue(function(plugin, callback) {
			logger.debug(plugin.file + ' init function called');
			var pluginFilePath = config.pluginManager.pluginsPath + plugin.file;
			logger.debug('pluginFilePath: ' + pluginFilePath);

			if (utils.isDefined(plugin.public) && plugin.public != "") {
				var pluginPublicPath = config.pluginManager.pluginsPath + plugin.public;
				app.use('/' + plugin.public, express.static(pluginPublicPath));
				logger.debug('Express: route ' + plugin.public + ' registered to folder ' + pluginPublicPath);
			}

			var pluginInstance = require(pluginFilePath);
			pluginInstance.init(plugin.args);

			callback();
		}, config.pluginManager.plugins.length);

		q.drain = function() {
			logger.debug('PluginManager::loadPlugins() all plugins have been started');
		};

		for (var i = 0; i < config.pluginManager.plugins.length; i++) {
			q.push(config.pluginManager.plugins[i]);
		}
	}
};


text:
<?php

/**
 * This code was generated by
 * \ / _    _  _|   _  _
 * | (_)\/(_)(_|\/| |(/_  v1.0.0
 * /       /
 */

namespace Twilio\Rest\Video\V1;

use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\Rest\Video\V1\Room\ParticipantList;
use Twilio\Rest\Video\V1\Room\RoomRecordingList;
use Twilio\Values;
use Twilio\Version;

/**
 * @property \Twilio\Rest\Video\V1\Room\RoomRecordingList $recordings
 * @property \Twilio\Rest\Video\V1\Room\ParticipantList $participants
 * @method \Twilio\Rest\Video\V1\Room\RoomRecordingContext recordings(string $sid)
 * @method \Twilio\Rest\Video\V1\Room\ParticipantContext participants(string $sid)
 */
class RoomContext extends InstanceContext {
    protected $_recordings = null;
    protected $_participants = null;

    /**
     * Initialize the RoomContext
     *
     * @param \Twilio\Version $version Version that contains the resource
     * @param string $sid The SID that identifies the resource to fetch
     * @return \Twilio\Rest\Video\V1\RoomContext
     */
    public function __construct(Version $version, $sid) {
        parent::__construct($version);

        // Path Solution
        $this->solution = array('sid' => $sid, );

        $this->uri = '/Rooms/' . \rawurlencode($sid) . '';
    }

    /**
     * Fetch a RoomInstance
     *
     * @return RoomInstance Fetched RoomInstance
     * @throws TwilioException When an HTTP error occurs.
     */
    public function fetch() {
        $params = Values::of(array());

        $payload = $this->version->fetch(
            'GET',
            $this->uri,
            $params
        );

        return new RoomInstance($this->version, $payload, $this->solution['sid']);
    }

    /**
     * Update the RoomInstance
     *
     * @param string $status The new status of the resource
     * @return RoomInstance Updated RoomInstance
     * @throws TwilioException When an HTTP error occurs.
     */
    public function update($status) {
        $data = Values::of(array('Status' => $status, ));

        $payload = $this->version->update(
            'POST',
            $this->uri,
            array(),
            $data
        );

        return new RoomInstance($this->version, $payload, $this->solution['sid']);
    }

    /**
     * Access the recordings
     *
     * @return \Twilio\Rest\Video\V1\Room\RoomRecordingList
     */
    protected function getRecordings() {
        if (!$this->_recordings) {
            $this->_recordings = new RoomRecordingList($this->version, $this->solution['sid']);
        }

        return $this->_recordings;
    }

    /**
     * Access the participants
     *
     * @return \Twilio\Rest\Video\V1\Room\ParticipantList
     */
    protected function getParticipants() {
        if (!$this->_participants) {
            $this->_participants = new ParticipantList($this->version, $this->solution['sid']);
        }

        return $this->_participants;
    }

    /**
     * Magic getter to lazy load subresources
     *
     * @param string $name Subresource to return
     * @return \Twilio\ListResource The requested subresource
     * @throws TwilioException For unknown subresources
     */
    public function __get($name) {
        if (\property_exists($this, '_' . $name)) {
            $method = 'get' . \ucfirst($name);
            return $this->$method();
        }

        throw new TwilioException('Unknown subresource ' . $name);
    }

    /**
     * Magic caller to get resource contexts
     *
     * @param string $name Resource to return
     * @param array $arguments Context parameters
     * @return \Twilio\InstanceContext The requested resource context
     * @throws TwilioException For unknown resource
     */
    public function __call($name, $arguments) {
        $property = $this->$name;
        if (\method_exists($property, 'getContext')) {
            return \call_user_func_array(array($property, 'getContext'), $arguments);
        }

        throw new TwilioException('Resource does not have a context');
    }

    /**
     * Provide a friendly representation
     *
     * @return string Machine friendly representation
     */
    public function __toString() {
        $context = array();
        foreach ($this->solution as $key => $value) {
            $context[] = "$key=$value";
        }
        return '[Twilio.Video.V1.RoomContext ' . \implode(' ', $context) . ']';
    }
}


text:
<?php

namespace Magento\Sitemap\Test\Constraint;

use Magento\Sitemap\Test\Page\Adminhtml\SitemapIndex;
use Magento\Mtf\Constraint\AbstractConstraint;

/**
 * Class AssertSitemapSuccessSaveMessage
 */
class AssertSitemapSuccessSaveMessage extends AbstractConstraint
{
    const SUCCESS_MESSAGE = 'You saved the sitemap.';

    /**
     * Assert that success message is displayed after sitemap save
     *
     * @param SitemapIndex $sitemapPage
     * @return void
     */
    public function processAssert(SitemapIndex $sitemapPage)
    {
        $actualMessage = $sitemapPage->getMessagesBlock()->getSuccessMessage();
        \PHPUnit_Framework_Assert::assertEquals(
            self::SUCCESS_MESSAGE,
            $actualMessage,
            'Wrong success message is displayed.'
            . "\nExpected: " . self::SUCCESS_MESSAGE
            . "\nActual: " . $actualMessage
        );
    }

    /**
     * Text of success create sitemap assert.
     *
     * @return string
     */
    public function toString()
    {
        return 'Sitemap success create message is present.';
    }
}